I18n page links seems randomly generated

Hi,

I have a problem with the translation links generated by the reference translated content template. Seems that every time I rebuild the site, the links are randomly generated and have nothing to do with the current page.

My content is organized as directories, so I have

/content/it
/content/en

I want to display a translation link at the bottom of the page so I’ve used the i18nlist.html template as listed in the documentation (nearly, I borrowed the actual template from a theme but the basic code is the same).

It works, however the links seems random each time.

For example:

    <li class="list f5 fw4 dib pr1">
        <a class="hover-white no-underline white-90" href="/en/tags/">English</a>
    </li>

After a new build without any changes:

    <li class="list f5 fw4 dib pr1">
        <a class="hover-white no-underline white-90" href="/en/downloads/">English</a>
    </li>

Another build:

    <li class="list f5 fw4 dib pr1">
        <a class="hover-white no-underline white-90" href="/en/404.html">English</a>
    </li>

And so on… each time I rebuild the site.

Seems that the links are randomly generated, and the links on all pages seems to be the same, in other words seems that the current page name is ignored.

I’m sure there is something I have not set correctly, but what ?

Thank you for any help.

You are more likely to receive a prompt and accurate response if you post a link to your project’s Git repository.

See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

Well, I did more debugging on the pages and found that if I place the translation links on the header they works correctly, but on the footer they show the “random” issue.
It turned out that the footer was included with the partialCached command:

    {{ block "footer" . }}{{ partialCached "site-footer.html" . }}{{ end }}

Removed the “Cached” part and it works well.
Probably the original theme I’m using wasn’t meant to place page-dependent things on the footer, for whatever reason.

So lesson learned: never use *Cached things unless absolutely necessary!

More like the footer should never be cached. If I were you, I would open an issue with the theme author.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.