Problem with baseURL with Github Action

With https://gohugo.io/host-and-deploy/host-on-github-pages/#article, this part --baseURL "${{ steps.pages.outputs.base_url }}/ added the repo name to the URL causing thousands of my links to break e.g https://example.com/foo became https://example.com/lorem/foo with lorem as repo name Google search console sent me a warning. This happened a few months ago, and I had to hard code the base URL.

Still trying to figure why this happened?

Does this GitHub Pages site have a custom domain?

Yes it does.

Is the “Custom domain” field in your settings populated?

It is populated. It is a subdomain. Like foo.bar.com

at the end something like that:

  • maybe you deleted your CNAME file in your published the root?
  • settings on your provider side changed for the cname?

I had to hard code the base URL

There is conflicting information as to how this should work. Or to put it another way, it is unclear to me if the build phase is aware of the custom domain setup. The deploy phase is, but that would be too late to populate steps.pages.outputs.base_url correctly.

If it were my site, I’d remove the --baseURL flag from the GItHub action, and instead make sure that the baseURL in my site config is correct.

That’s not a very satisfying answer, but anything more would require some testing that I don’t have time for at the moment.

Github pages never requested/made a cname file after adding the subdomain.

I will test this and see. (Sad that Cloudflare Pages has a 20k workers limit)