When I build my site locally using “hugo serve”, everything is great.
When I deploy to gitlab, using hugo --baseURL="username.gitlab.io/sitename/" in the .gitlab-ci.yml deployment script (Gitlab and Hugo), then all the images referenced in the /static/ folder don’t load properly. And if I try any other basURL argument, then the navigation to the content doesn’t work. How do I work around this?
In response to suggestion regarding protocol, it looks like I was including http://; just did not type question correctly here. Another reason better to link to source…
Ok, looks like images is right under static which I think is typical, but you’re copying the site up into /TradingSite? That’s where that extra URL path is coming from… I think.
I have changed the deployment file to say hugo --baseURL="http://pyrex41.gitlab.io/"; you should be able to see this in the repository now. It does not appear to have changed anything though…
If by that you mean the images not showing, you need to set the short codes to have the right path. You were specifying /images but there is nothing there. Instead, try & specify /TradingSite/images when you set their path.
I️ will give that a try. I️m confused about what baseURL Is used for then. I️ thought the links in the shortcode would automatically have baseURL prepended to them.
Ok updating the short codes works. However the same issue seems to be affecting some aspect of the CSS rendering. Do you have any suggestions on where it look for this?
Looks like you found it. Your header partial refers to a css partial which uses params in the config. However, there are no params set to this, so doing what you did makes sense.
I have been able to use relURL to avoid having to hard code /TradingSite/ by doing the following:
I created two custom shortcodes: myimg: <img src = "{{ .Get "src" | relURL}}" alt=""> download: <a href="{{ .Get "href" | relURL}}" download="{{ .Get "download" }}">{{ .Get "text" }}</a>
These shortcodes can then be used in content creation without having to think about what the baseURL for the site is.
Similarly, I updated the partials/css section to also refer to relURL: <link rel="stylesheet" href= {{ "/css/main.css" | relURL }}>
This now works equally well when deployed on development server (baseURL = "http://example.com") or when pushing to some other baseurl (eg, baseURL = "http://user.gitlab.io/sitename/").