How to translate multiple paginated posts?

I have been using the multipage solution by @jmooring for a while now but I have stumbled upon an issue with translations. I translate my posts by content directory. However, When I am on a paginated page of the multipage, and I toggle the language menu, the translation points back to page 1 of the multipage rather than show the equivalent file/page open at that moment. Is this an unexpected behaviour or a limitation of the multilingual option in Hugo? (even setting translationKey does not work)

If it helps, I tested the working example in the link and it also reproduces the issue.

@jmooring any idea? I am trying to see if this is the expected behaviour before I commit more resources to pages of this kind.

This is a known issue, related to pagination:

Your language switcher code is probably something like:

{{ with .AllTranslations }}
    {{ range . }}
      <a href="{{ .RelPermalink }}">{{ .Language.LanguageName }}</a>
    {{ end }}
{{ end }}

In this code .RelPermalink will not include the pager path.

This behavior is not specific to the multipage article recipe that I provided in topic #29161.

For an alternate implementation of multipage posts that does not use Hugo’s pagination feature, see this example:

git clone --single-branch -b hugo-forum-topic-40858 hugo-forum-topic-40858
cd hugo-forum-topic-40858
hugo server

This approach uses .Pages.Next and .Pages.Prev to build the navigation from one page to the next.


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