hugo icon indicating copy to clipboard operation
hugo copied to clipboard

Site not generating URLs that start with language code

Open idarek opened this issue 5 years ago • 8 comments

hugo v0.82.0+extended darwin/amd64 BuildDate=unknown

I tend to have my website in Polish and I added English version in my local development.

When config.toml contain only one language pl there was not issue with generating posts URL's.

When I added English language along with Polish, where Polish is in / and only english in /en/, posts with URL starting with language code doesn't generate.

for example, post with

url: '/placek-wloski/'

will not generate, because contain /pl on front (!) despite that DefaultContentLanguage = "pl" is set and Polish site is not served in /pl/ folder

I can change on same post URL to, lets say /xxplacek-wloski/ and it will open correctly because /pl is not on front of URL

idarek avatar Apr 21 '21 21:04 idarek

I can confirm that issue is existing with English part of the website that by default have /en/ set.

For example: url: '/test-post/'

will work on localhost:1314/en/test-post/ however if you change it to url: '/entest-post/'

it will not work, as contain /en on front.

idarek avatar Apr 21 '21 21:04 idarek

Removing all reference to languages from config [languages.xxxxx] revert site to solo-language and all links working fine. Adding disableLanguages doesn't fix the issue, only removing [languages] part all together.

idarek avatar Apr 21 '21 21:04 idarek

Through further investigation, the issue happening when each language got set its own baseURL.

Example

[languages]
  [languages.pl]
    baseURL = "https://dariusz.wieckiewicz.org/"
 (...)
  [languages.en]
    baseURL = "https://dariusz.wieckiewicz.org/en/"
(...)

idarek avatar Apr 22 '21 20:04 idarek

Temporary solution.

Change language names DefaultContentLanguage = "polish" instead pl (and because of that i18n need to renamed from pl.toml to polish.toms along with config parts [languages.pl] to [languages.polish].

This will allow me to generate posts that URL start with /pl... as long as not starting with /polish...

still, if I want English to be in /en need to avoid starting my post url with /en... for English language (this doesn't affect other language).

idarek avatar Apr 22 '21 20:04 idarek

The issue happens only, when in [languages] each language got specified baseURL.

idarek avatar Apr 23 '21 18:04 idarek

Related to or duplicate of:

  • #7907
  • #7733

jmooring avatar Apr 23 '21 18:04 jmooring

Related to or duplicate of:

  • #7907
  • #7733

It looks like, worth to merge them some point.

idarek avatar Apr 23 '21 22:04 idarek

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.

github-actions[bot] avatar Jul 19 '22 02:07 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Oct 05 '22 02:10 github-actions[bot]