Is it possible to translate the path of a section? I’ve this situation:
de is my default language. Currently the German page is available via
/imprint and the English one is
/en/imprint. Is it possible to override the url of the German page to
I figured it out. I just don’t use
_index.xy.md files but
imprint.xy.md in the content root. Then I could override the url with the frontmatter parameter
url. Maybe it should be somewhere documented, that some frontmatter params have no affect in frontmatter.
Could you explain that differently? We definitely want to make the docs clearer, but I am not picking up the part that wasn’t working for ya.
_index.html pages are not used for single pieces of content, it is to modify the values for list pages.
I understand that
_index.html pages are not used for single pages. What I tried is to rename the section from the
_index.html file for a certain language. I’ve found in the documentation, that it’s possible to override the URL or parts of it with some frontmatter parameters.
For example I wanted, that the German version of the
imprint page is accessible via
/impressum, so I added
url = /impressum to the frontmatter in
_index.de.md. Surprisingly this didn’t have any effect. I was searching the documentation, if this is because it’s an
_index page, but I didn’t find anything.
I hope I explained it better this time
I have the same issue. There is no way to translate the section name (taken from directory name in the filesystem) to another language in a multilingual mode. Neither slug nor url in the frontmatter work.
content/news/_index.ru.md which define a section for news posts. Default section name is
news for both languages, despite
slug: новости or
url: новости in the
@bep is it a bug and should it be fixed?
For what it’s worth, there is already an issue for it on GitHub: https://github.com/gohugoio/hugo/issues/3354
I get stuck with this issue with Japanese. My solution so far has been to use the permalinks setting in my
config.yaml to fix the subpages, and then put a fairly ugly workaround with another, custom
config param into all my shortcodes/partials that generate links, and use Netlify rewrite rules to make the translated links serve the untranslated page.
So, all the links (from menus in particular, which I use to do multilingual cross references) except for
.Translation links (which I just can’t fix) are to my desired URL and when it’s navigated to, Netlify serves the original page on that preferred URL with a 200 response.
It is as designed. Not a bug. What I suggest is to use a generic term for the section name (i.e. the folder) and put the translations in the title.
How to change the url of a section using translations in the title?
I suppose current sections/folders were designed a long time before the multilanguage feature. Newly added _index.md logically fits into customizing /section/ behavior, and slug/url frontmatter support seems natural.
If it’s impossible to translate section’s url, what are other possible workarounds with a similar behavior (e.g. listing all pages in a section, easy menu support, etc.)? Looks like many people are interested in it, including me (also github issue and other topic on the forum Override section url)
You can not. Which is also by design. This may be improved on in the future, but there are very few complaints about this.
So it is not a bug, which was my point. A bug is a unforseen defect.
In my head, encoding language into URLs isn’t super-important.
It improves SEO and readability for users (both in search engines results and on a site itself).
Sure, but for me it is not important. Which was my point. And I’m not sure you are right about the SEO etc., but that is not important.
I keep my folder names in my primary language and overwrite the url of other language files via url: in frontmatter. not nice to maintain, but actually the quickest solution.
Thank you, it is a pity that English-only speakers do not value the richness of mutilanguage in URLs
Exactly. I don’t understand when someone does not see the value in something obvious. And this not even matter if someone things it is important; such thing is really easy to add, its just matter of the will at the end.