Consider this Front Matter:
Title: What we do
slug: what-we-do
Depending if it's from a Leaf Bundle or regular md file Hugo will build the url differently:
content/about/services/misc.md> http://site.com/about/services/what-we-do/ ✅
content/about/services/misc/index.md> http://site.com/about/services/misc/what-we-do/ 🚫
Agreed, I just ran into this issue myself.
My use-case is more blog oriented and I have bundle folders for every post. It's a large number of posts, so they really need to have a date or other number in the directory name, but I'd rather not expose that in the public URL.
My workaround for now is to set an explicit url: value in the front matter.
The behavior here is very different for content in content/post vs. content/anything-else.
The tool I was using to export content defaulted to content/posts (note the plural), which results in the behavior described above.
Now that I've learned that content/post has some magic associated with it, I'll be more careful.
I just stumbled upon this on a multi-lingual website, the slug gets added to the page bundle:
content/en/localization/index.md > /en/localization/ ✅ content/fr/localization/index.md > /en/localization/localisation/ 🚫 I had to set an url to get it fixed.
Same issue as @DirtyF
I encountered the same issue because with my previous CMS Grav I was using the slug in the Leaf Bundle to specify the URL in other languages.
To workaround, I configured the permalinks in the config.toml like this (with blog being the section name):
[permalinks]
blog = "/blog/:slug/"
However you must check that the URLs are like you wish. In my case, some French articles got accents in their path while before they didn't had so I had to precise the slug for those articles in the front matter.
Update:
Finally, in order to avoid to add a slug to my French articles, I configured the permalinks per language:
[languages]
[languages.en]
[languages.en.permalinks]
blog = "/blog/:slug"
[languages.fr]
[languages.fr.permalinks]
blog = "/blog/:filename"
Update:
You can remove accents from URLs by adding one parameter to your configuration file: RemovePathAccents = true
This is beginning to be be noisy in the discourse, so: shameless bump 🤷♂️
I have the same problem of @regisphilibert and @DirtyF here... Just to add something to conversation:
In the multilingual docs page, slug's use is explained as below:
To localize the URLs, the
slugorurlfront matter param can be set in any of the non-default language file.For example, a french translation (
content/about.fr.md) can have its own localized slug.
Title: A Propos
slug: a-propos
At render, Hugo will build both
/about/andfr/a-propos/while maintaning their translation linking.If using
url, remember to include the language part as well:fr/compagnie/a-propos/.
But this is not what happens, as explained in this issue.
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
Most helpful comment
I just stumbled upon this on a multi-lingual website, the slug gets added to the page bundle:
content/en/localization/index.md>/en/localization/✅content/fr/localization/index.md>/en/localization/localisation/🚫I had to set an
urlto get it fixed.