Hugo site has a mix of sub-domain and primary domain web pages

Hello Netlifies

I’ve have a small but annoying thing on my Hugo Site, that doesn’t affect the running of it but bugs the hell out of me.

My Hugo site is https://www.strategyxdesign.co.uk/

When I navigate any of the items from the main menu such as the my main newsletter page www.strategyxdesign.co.uk/hypernormal/ it uses the primary domain as intended.

But if I were to go down a level to a specific newsletter it switches to the default subdomain page dreamy-raman-bdb88a.netlify.app/hypernormal/001/

Instead I would want www.strategyxdesign.co.uk/hypernormal/001/

How do I correct this? Is this a Hugo config thing or a netlify issue?

I’d bet on Hugo config.

You might be using {{- .Permalink -}} to display those links. Switching it to {{- .RelPermalink -}} would do the trick. If you share your repo I can exactly point at the error or else it’s a guess work.

1 Like

@hrishikesh probably provided the answer to this, but a workaround would be to set up redirects from your Netlify sub-domain to your primary custom domain in your _redirects or netlify.toml file.

Thanks for the suggestion.

My repo is located here: GitHub - TeldridgeLDN/servicexdesignv2

Looks like that would do it. You’ve a file here: /themes/hugo-kiera/layouts/_default/list.html - line 19 which has the .Permalink. However, I am confused, you’ve the correct URL set in your config.toml. So it should not have been a problem. What is your build command?

1 Like

I don’t use Hugo, but I note that your config file points to your apex domain instead of to your preferred www custom sub-domain, so you have a couple of edits to make.

1 Like

It was Netlify build command. It was set to hugo --minify --baseURL https://dreamy-raman-bdb88a.netlify.app/

I changed it to hugo --minify --baseURL https://www.strategyxdesign.co.uk/ and it worked

Had thought so. However, you don’t need to add the --baseURL in command. You already have the value in config.toml. So, removing it is advisable.

However, the real solution would be to switching to .RelPermalink so it can work fine regardless of all this mess.

1 Like