baseUrl, relUrl quirks in Netlify #6
-
I use Netlify for most of my CICD and hosting needs, and I'm running into an issue where no matter what the baseUrl is set to (e.g., "", "/", "www.something.com"), the relUrl of the menu links will point to the baseUrl and not the relative path of the content directory. This does not happen when serving locally. The exact issue is pointed out here: https://answers.netlify.com/t/redirects-in-page-not-updating-url-correctly-when-deploying-from-github/13135. However, the fixes they propose have not been working for me. Unfortunately I'm not able to get it to work for my site. My live site in Netlify: https://www.chaosish.com/ Any idea why this is happening and how to get the relative path to work nicely in the menu? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Thanks for the question. This seems strange to me because I use Netlify to deploy this theme on two separate sites. Part of the reasoning behind using relative URLs in the theme is to enable deployment to different hosts. What I'm doing for my own site is this: # netlify.toml
[build]
command = "hugo mod get -u && hugo --gc --minify -b $URL"
publish = "public"
[context.production.environment]
HUGO_VERSION = "0.87.0"
HUGO_ENV = "production" The |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply! I copied your netlify.toml file exactly and set the baseUrl to my domain as documented in the Congo docs. It worked! I suspect this is just due to a quirk with how Netlify handles baseUrl when serving the public folder, or when running the hugo command to create the build artifact. Of course when running hugo server locally, every which variation worked. Thanks again for your help! |
Beta Was this translation helpful? Give feedback.
Thanks for the question. This seems strange to me because I use Netlify to deploy this theme on two separate sites. Part of the reasoning behind using relative URLs in the theme is to enable deployment to different hosts. What I'm doing for my own site is this:
The
-b $URL
is setting the baseURL in Hugo to wherever Netlify is deploying to. Then in my Hugoconfig.toml
I don't set any baseURL or other parameters that change the URL structure.