matcornic / hugo-theme-learn

Porting Grav Learn theme to Hugo
https://learn.netlify.com/en/
MIT License
1.6k stars 1.28k forks source link

Issue with setting landingPageURL being reliant on languages #525

Open amlwwalker opened 2 years ago

amlwwalker commented 2 years ago

If you want to serve Hugo using this theme on xyz.com/tutorials

then in config.toml you can set

baseURL = 'https://xyz.com/tutorials'

this will fix all the links between pages to use the /tutorials path as part of every URL

However this doesn't fix the "Home" or Icon links, which take you to the root of the domain (i.e xyz.com) rather than xyz.com/tutorials.

Looking at the code for these:

The logo has the link:

<a id="logo" href='{{ (cond (and (ne .Site.Params.landingPageURL nil) (.Site.IsMultiLingual)) .Site.Params.landingPageURL "/") }}'>

and the Home button has the link

<a class="padding" href='{{ (cond (and (ne .Site.Params.landingPageURL nil) (.Site.IsMultiLingual)) .Site.Params.landingPageURL "/") }}'>{{ safeHTML (cond (ne .Site.Params.landingPageName nil) .Site.Params.landingPageName "<i class='fas fa-home'></i> Home") }}</a>

in both cases then it suggests that setting the landingPageURL='/tutorials in config would be what is required however, and I think its a bug, this actually would only work if multiple languages are set, i.e to be able to specify a path on the Home/logo links you need multi language (IsMultiLingual) but you don't need multilanguage to update the base URL?

I think that there is a bug that means that the path/url for these is reliant on multi language and that shouldn't be a requirement?

Shouldn't the baseURL be the default (otherwise / ) for Home/Icon link?

McShelby commented 2 years ago

This was fixed by @helfper in the fork. Feel free to check it out.