How to set Hugo baseURL with custom domain

Sat, Oct 3, 2020 One-minute read

Hugo’s documentation is not entirely clear on the format of the baseURL value in config.toml when using github pages with a custom domain. When using a custom domain, you need to add the file static/CNAME whose contents are only the CNAME of your site (www.sebortiz.com in the case of this site). However, the baseURL value does seem to require the protocol as well (I guess this is implied by URL in the name…), so in the case of this site https://www.sebortiz.com.

Note that setting a blank baseURL, i.e. baseURL="" will do something that is almost certainly not what you would intend. It ends up creating URLs with paths that are relative to the current page you are viewing which will potentially break image paths,etc. depending on what page you are on.