amlwwalker
amlwwalker

Reputation: 3314

Hugo change landingPageURL so that links point to path not URL root

hey i am struggling with a hugo issue my blog is hosted at xyz.com/blog so to get my URLs to pages working I have added baseURL = 'xyz.com/blog/' to my config.toml file

This works for all page (markdown page) links, however the issue I am having is that the logo/Home link in the menu (theme is hugo-theme-learn) don't update and always end up linking to the root domain / I can see from the template that the logo is linked from

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

and the home menu button is linked from

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

what I can't seem to get working is setting .Site.Params.landingPageURL in the config? I have tried setting

[params]
landingPageURL='https://xyz.como/blog'

but it doesn't seem to have any effect whatsoever on these two links and they still end up pointing to /

Any help appreciated. Thanks

Upvotes: 0

Views: 1061

Answers (1)

Rogelio
Rogelio

Reputation: 1046

Note: This is a theme specific question - this question or any code updates you propose should go to the maker of the theme, editing the theme yourself, defeats in a small part, the purpose of using a theme.

So, pardon, I'm having difficutly tracking totally and the quoted code is overly complicated (I assume it's from the theme) and maybe has a greater purpose, but if you are in fact trying to link to the baseURL, then just do so:

.Site.BaseURL

Or

site.BaseURL

That will return your baseURL... which from your explanation I believe is what you are trying to connect to.

So:

<a href=".Site.BaseURL">Home</a>

But, even more so:

<a href="/">Home</a>

If Multilanguage is set-up correctly - does work (at least on the multiple multi-language sites I administer in hugo).

But, again you are then breaking the theme.

Upvotes: 0

Related Questions