Hello everyone, I am new to Hugo and I have been struggling with an issue for a few days, so any help would be appreciated.
I have developed a website locally with Hugo using the Poison theme. As soon as I change the baseURL to "https://<username>.github.io/<repository>" all my different pages stop working (About, Posts, and Projects) and they lead to a 404 error like this
My logo image (called brand image in the theme) loads properly locally even after changing the baseURL value but after the deployment on Github pages, it breaks. The theme guide states that: NOTE: To display an image in your sidebar, you’ll need to uncomment the brand_image path below and have it point to an image file in your project. The path is relative to the static directory. In my hugo.toml file I have done just that and like I said it works locally but breaks after deployment even though the path is still the same, I am trying to solve this issue too. Thanks in advance!
Check your baseURL. It points to a subdirectory https://darrylat.github.io/scorpiosec/. Note that if you intend to use a custom domain, it should match your baseURL including the https protocol.
How so? It is pointing to the main directory that is hosting all the Hugo files. I followed the " Hosting and deployment " documentation on the Hugo website. If that is wrong what should the URL be? I do plan on using a custom domain later, but I want the site to be functional before I buy the domain.
I see that the baseURL should follow this style baseURL = "https://<username>.github.io/<repository>" which it does in my case. The link was provided after I used Github actions to deploy the site
The theme uses the URL values as is, without running them via any of Hugos URL functions. This way the link do not know anything about the sub directory and then become:
https://darrylat.github.io/about/
instead of:
https://darrylat.github.io/scorpiosec/about/
You can politely ask the theme author if they are interested in working on this issue.
Another “fix” is to update all the URLs on your site to have the sub directory hardcoded. But if you ever move the site to a proper domain you will need to redo that.
I didn’t type this URL specifically, after deploying the website I tried to navigate the website as a normal user and notice that all the pages are breaking. I see now that is because it is using the wrong URL but that is the issue I don’t know why it is doing that. Same as to why the logo image is not showing despite following the instructions provided by the theme’s docs.
First thank you for your detailed answer, I understand the issue better now.
So if I understand correctly I will need to specify the URLs in the menu param as in URL = "https://darrylat.github.io/scorpiosec/about/" for the About page for example, and do the same for the Posts page and Project page too?
Do you think the logo image breaking is also caused by the same issue?
I think the theme (or I don’t know what else at this point) does not recognize that URL I tried the new one {Name = "About", URL = "/scorpiosec/about/", HasChildren = false}, and it does not work. It just removes the About section