Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom slug is appended to bundle directory name #4870

Closed
regisphilibert opened this issue Jun 22, 2018 · 7 comments

Comments

@regisphilibert
Copy link

commented Jun 22, 2018

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/ 🚫

@misterbisson

This comment has been minimized.

Copy link

commented Sep 21, 2018

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.

Update

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.

@DirtyF

This comment has been minimized.

Copy link
Contributor

commented Sep 26, 2018

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.

@erolabzait

This comment has been minimized.

Copy link

commented Nov 28, 2018

Same issue as @DirtyF

@KillianKemps

This comment has been minimized.

Copy link

commented Jan 5, 2019

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

@regisphilibert

This comment has been minimized.

Copy link
Author

commented Jan 25, 2019

This is beginning to be be noisy in the discourse, so: shameless bump 🤷‍♂️

@jzeneto

This comment has been minimized.

Copy link

commented Jan 30, 2019

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 slug or url front 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/ and fr/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.

@stale

This comment has been minimized.

Copy link

commented May 30, 2019

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.

@stale stale bot added the Stale label May 30, 2019

@bep bep added the Keep label May 31, 2019

@stale stale bot removed the Stale label May 31, 2019

@stale stale bot removed the Stale label May 31, 2019

@bep bep added this to the v0.56 milestone May 31, 2019

@bep bep added Bug and removed Keep NeedsInvestigation labels May 31, 2019

@bep bep self-assigned this May 31, 2019

bep added a commit to bep/hugo that referenced this issue May 31, 2019

@bep bep closed this in #6005 Jun 9, 2019

bep added a commit that referenced this issue Jun 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.