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

Consider relative url vs lang prefix #5818

Closed
bep opened this Issue Apr 5, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@bep
Copy link
Member

commented Apr 5, 2019

I saw a multilingual site in the wild with this front matter:

url: en/pictures

Since we in Hugo 0.55 supports page-relative URLs in front matter (a good thing!), the above would end up below /en/en/pictures/, which is obviously not correct.

Both of the below would produce correct output:

url: /en/pictures
url: pictures

I suspect that it is more common than not to have a leading / in URLs, but I will think about the above and consider if we can add an additional check (I thought we did).

/cc @divinerites

@bep bep self-assigned this Apr 5, 2019

@bep bep added this to the v0.55 milestone Apr 5, 2019

@divinerites

This comment has been minimized.

Copy link

commented Apr 5, 2019

Hey Bep !! Thanks for the cc:
Just to give some context about my use case for that.

If I juste use folder and file name automatically created by hugo out of the box it works fine.

But it doesn't goes well with SEO because file names/url/contents are quite differents.

So in order to keep SEO happy I had to change url name to be consistent with each language (ex : hiking/randonnees).

And I couldn't find an other workaround than putting the language prefix in urls (en/hiking, fr/randonnees).

But avoiding to have hardcoding language in URL would be perfect.

@bep

This comment has been minimized.

Copy link
Member Author

commented Apr 5, 2019

If I juste use folder and file name automatically created by hugo out of the box it works fine.

Sure, I have no problem with the "why" -- my motivation behind this issue is to reduce the number of questions/issues about this particular issue once we release 0.55. I so I might add another check.

bep added a commit to bep/hugo that referenced this issue Apr 7, 2019

hugolib: Log warning on relative front matter url with lang
Will do this for one version only, as there may be situations where this is the correct thing.

Fixes gohugoio#5818
@Brixy

This comment has been minimized.

Copy link

commented Apr 7, 2019

Sorry: I am not sure whether this is related.

The reason why I need to use e.g.

url: /fr/a-propos/

is because

slug: a-propos

results in this URL: /fr/about/a-propos/.

If helpful, I can upload a minimal working setup.

Edit

Just to specify: This problem only occurs when a folder is used—as described here

.
└── content
    └── about
    |   └── index.md
    |   └── index.fr.md
    |   └── index.es.md
@divinerites

This comment has been minimized.

Copy link

commented Apr 7, 2019

just to report that I removed all my en/, nl/, ... from url front matter. My use case works like a charm and as expected I do not have to worry to add language as a prefix any more.

The warning will be helpfull tho.

bep added a commit to bep/hugo that referenced this issue Apr 7, 2019

hugolib: Log warning on relative front matter url with lang
Will do this for one version only, as there may be situations where this is the correct thing.

Also add some more related test cases.

Fixes gohugoio#5818

@bep bep closed this in #5823 Apr 7, 2019

bep added a commit that referenced this issue Apr 7, 2019

hugolib: Log warning on relative front matter url with lang
Will do this for one version only, as there may be situations where this is the correct thing.

Also add some more related test cases.

Fixes #5818
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.