Hugo styles not showing up on Github Pages, though it loads locally -- issue seems not due to baseURL

Hi Kaizen,

Big thanks for your warm words to the community.

I read your blog post (currently seems to be offline) and there you wrote about adding an absUrl variable to the hugo config file. Cannot verify if that’s what you did as your repo is not readable for me.

I would think about using the absURL, which is a hugo function in the partial to include the css. Also suggested by @davidsneighbour in his answer No need for a site variable there.

      <!-- link with function -->
      <link rel="stylesheet" href="{{ absURL "css/styles1.css" }}" />
      <link rel="stylesheet" href="{{ absURL "css/styles1.other" }}" />

you could use a loop in your head.html partial

      {{ with $myBase := absURL "" }}
         <link rel="stylesheet" href="{{ $myBase }}css/styles2.css" />
         <link rel="stylesheet" href="{{ $myBase }}css/other2.css" />
      {{ end }}

using baseURL = "https://www.example.com/garden/" in in hugo.toml
this will render locally to:

    <!-- link with function -->  
      <link rel="stylesheet" href="http://localhost:1313/garden/css/styles1.css" />
      <link rel="stylesheet" href="http://localhost:1313/garden/css/styles1.other" />

    <!-- loop with variable -->  
         <link rel="stylesheet" href="http://localhost:1313/garden/css/styles2.css" />
         <link rel="stylesheet" href="http://localhost:1313/garden/css/other2.css" />
2 Likes