HUGO

Language selection list missing from 404 page header

I am using the same header.html partial to render the header for both my normal pages(calling it in baseof.html) & for the 404 page as well. But the 404 page seems to be rendering the header differently.
The templating of my 404 page is here.

Links:

What do you mean by rendering the header differently?

The only difference that I see is that the languages selection list is missing from the 404.html header.

As per L37-L56 in /partials/header.html the language menu is within an if .IsTranslated condition.

The 404.html does not have a corresponding translated page therefore the language list is not rendered.

1 Like

Sorry, I just now updated the repo to replicate the problem clearly. If you see for all pages this dropdown menu is appearing:

Whereas on the 404 page this dropdown menu it is not appearing. This is what I meant by rendering the header differently.

Thanks for pitching in @onedrawingperday

Not on my end.

Homepage:

404.html

Again the only menu missing is the language selection.
Also it seems that you have some CSS issue as in the 404.html the menu is rendered in bold.
It looks like that a class is missing.

If you click on the people link, then the sub menus are missing in the 404 page. Where as the sub menu appears on all other pages. That’s the problem.

In other words, the main menu is rendering correctly, as you have shown. But the dropdown menu (or the sub menu) is not rendering in the 404 page.

Thanks again @alexandros .

The children of the dropdown menu are present in the source of the 404.html

<div class="dropdown-menu">
<a class="dropdown-item" href="/abc" title="Abc">Abc</a>
 <a class="dropdown-item" href="/def" title="Def">Def</a>              
</div>

I do not know why the dropdown menu does not work on the front-end of the 404.html.

It may be either a CSS or JS issue, in any case this is beyond the scope of this forum’s support.

Thanks @alexandros for pointing out about CSS & JS. Indeed the script partial having all the links to JS files was missing in the 404 page. Including this solved the problem.

@alexandros I have removed the if condition here. Now the language selection list appears on all pages except the 404 page. On 404 page, the <select> element is created but the <option> elements are not populated.

How do I make it appear on the 404 page ?

That code block is still looking for a translated page.

I suggest that you hardcode the language links in the 404 page template.

Make sure to keep the HTML so that it looks the same as in other pages.