When I make changes to a site I use hugo server to test the changes and then build the site using hugo. Randomly the site will be built using the local paths for links and images rather than the path specified with baseURL. Building the site again after discovering this will usually, but not always fix it. This applies to hugo 153 and I tried reverting to 151. The sites use themes theme-hugo-foundation6, which I’ve fixed from time to time and kraiklyn. All the sites were originally created some time ago and it’s possible I’ve missed something that should be in the site config file.
URLs of the two sites affected recently: blog/blog at master · billthefarmer/blog · GitHub , Bill Farmer , blog/gurgle at master · billthefarmer/blog · GitHub , Gurgle .
Update: I’ve just tried hugo 154 and it worked correctly. Whether it will next time is indeterminate.
When building your site locally for a production deployment, make sure you delete the contents of the public directory before running the hugo command.
When building the site using a CI/CD workflow (e.g., GitHub Pages, GitLab Pages, Netlify, Cloudflare, etc.) you don’t have to delete the public directory before pushing your changes, unless you have placed the public directory under source control, which you should never do.
1 Like
Thank you for this. However there’s nothing in the public directory of the blog site, the other site doesn’t have one. Most of the sites I have created don’t have one. I assume the hugo new site command stopped creating them at some stage.
This is something unique to your process. Such “random” behavior would have been found and fixed immediately.
This is true. However I have been building sites using this method off and on since 2017 and this has only started happening recently. Because it’s random it’s difficult to pin down a hugo version where it started. This is why I said…
All the sites were originally created some time ago and it’s possible I’ve missed something that should be in the site config file.
All the sites have a baseURL and a publishDir entry in the config file. The publishDir entry points to a folder which is published via Github pages, either in the billthefarmer.github.io project or in a project docs folder.
Hi mister bill. I’m not certain I’m following, but have you tried using the –cleanDestinationDir option when you build?