No styling - baseurl and Jenkins struggles

Hello everyone,

I am working on a documentation for my team. We are using Jenkins pipeline for one big framework and with each push to main we would like our documentation updated - we had this working till now with DocFX but we reached it’s limitation.

We moved to Hugo - using theme Doks (GitHub - h-enk/doks: Hugo theme helping you build modern documentation websites.).

In our pipeline we run npm install and npm run build. Then we publish html file as an artifact.
Currently I am in PR pipeline and the link for hosted documentation ends up as:

When it’s finally in “production” on main branch it would be (haven’t tried, but DocFX is currently like this):

We got Hugo working and managed to automate building of the docs.
We are calling npm install and npm run build. Then we publish the html index file in the public folder.

Problem is, there is no styling and the links are broken - my main suspect is setting the baseurl in config.toml. What do I change it to though? (Can I have url that works both for PR builds and main build using some wildcard?

Tried stuff like “/”, “job/repository-name/job/pull-41922%252Fmerge/Docs/”, “”.
All yield no result - I am hoping to first make it work locally but failing with that as well.

Locally only result works when I set baseurl to “/” and my styling and links work correctly using npm run start - not when opening index.html when using npm run build.

Am I perhaps approaching this wrong?

IIRC, then Jenkins by default disables serving some filetypes for artifacts, including js and maybe even css files. I think you have to tweak the security policy: Configuring Content Security Policy , but it’s been a while so it might be another setting

But locally it doesn’t work as well when opening index.html?

Can you share your source code? If you can run hugo serve locally so maybe it’s a problem with the rest of your pipeline and not with Hugo, who knows.

From my understanding npm run start or hugo serve spins of a web server, right?
I can do npm run start locally fine.

Problem is when I do npm run build and I open index.html - which is being published in my pipeline.
Is that not doable? Or is there problem with generated files?

Can’t really share the source code, might be able to delete confidential stuff but might take while - if we don’t get anywhere will do that.

How are you opening index.html?

In case of local:
I open up the public folder and just double click the index.html.

  • I suspect I need service running to actually host it then?

In case of Jenkins:
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: false,
reportDir: ‘Docs/public’,
reportFiles: ‘index.html’,
reportName: ‘Docs’,
reportTitles: ‘’

Yeah, that’s not going to work, unless the site has been very carefully crafted for this use case. The site needs to be served.