Skip to content

baseUrl, relUrl quirks in Netlify #6

Answered by jpanther
jacobleistra asked this question in Q&A
Discussion options

You must be logged in to vote

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 -b $URL is setting the baseURL in Hugo to wherever Netlify is deploying to. Then in my Hugo config.toml I don't set any baseURL or other parameters that change the URL structure.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@leiluspocus
Comment options

Answer selected by jacobleistra
Comment options

You must be logged in to vote
1 reply
@jpanther
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants