Viewing a site without a server

Hello,

I am building a website where the localhost version created via hugo server and the Github Pages version look fine. However, when I try to render the page locally, I get the bare HTML without any working CSS.

A repo of the site can be found here, the Github Pages version with working CSS can be found here.
Here is a screenshot of how the index.html when running hugo locally to render the page to the public folder:

cfc-local-render

It seems that the integration of the CSS does not work, as this is how the code looks like in the index.html in the public folder:

<link type="text/css" rel="stylesheet" href="/climate-friendly-cooking/css/schemes/climate.min.44c7861699f060e76e40634b2ffc9fca3e002014dfb8fbcc10b3b9b4aa3260977de9511a728cc8f60b2e28d5ab94907287ad269ffc78ec8184fa752815bcc34a.css" integrity="sha512-RMeGFpnwYOduQGNLL/yfyj4AIBTfuPvMELO5tKoyYJd96VEacozI9gsuKNWrlJByh60mn/x47IGE&#43;nUoFbzDSg==" />

In my public folder, I do not have the subfolder /climate-friendly-cooking/css/schemes/ - instead, the CSS can be found in /css/schemes/.

I suspect that something is wrong with baseURL and the use of relative URLs, but I did not find a way to fix this. Could you please help me understand how I can render the site properly to my public folder?

Thanks in advance for your help!

(EDIT: Forgot to mention my local hugo version: hugo v0.89.4-AB01BA6E+extended windows/amd64 BuildDate=2021-11-17T08:24:09Z VendorInfo=gohugoio)

See:
https://discourse.gohugo.io/t/open-built-website-from-local-folder-without-running-a-server/34193/2

To build your site for use without a webserver (i.e., navigating to public/index.html and then opening the file with your browser) requires:

  1. baseURL = "/" in site configuration
  2. uglyURLs = true in site configuration
  3. relativeURLs = true in site configuration
  4. Removal of all integrity attributes on CSS, JS. See themes/congo/layouts/partials/head.html.

And you will still run into some issues, most notably that Hugo sets the home page permalink to “/” instead of “index.html” when uglyURLs is enabled.

Not sure it’s worth the effort when you can just… hugo server

Hi Joe,

Thanks for linking the other thread and describing the challenges in a bit more detail.
I had mainly looked into public as a last check before pushing things to a server on the internet - in addition so simply trusting hugo server. But yes, given these challenges, I’ll trust whatever hugo server is showing me. Thanks for your help!