Hugo public not Rendering css (attaching localhost/) but Hugo server does

Hi Guys,

I did this
<link rel="stylesheet" href="{{ "css/style.css" | relURL}}">

it doesn’t render the css properly on the hugo server it works. The rendered file attaches localhost/to the css path. I tried making the BaseURL = “/”, that didn’t work as well.

What is the absolute path to style.css?
What is the baseURL in your site configuration?

base url is
BaseURL = “/” I am testing this on my local machine.

absolute path is css/style.css in asset folder

└── css/
    └── style.css
{{ $css := resources.Get "css/style.css" }}
<link rel="stylesheet" href="{{ $css.RelPermalink }}">

Apologies for that sample I shared up there

The css is in static

The asset was for a different project

└── css/
    └── style.css
<link rel="stylesheet" href="/css/style.css">

I noticed when I have the href as “/css/style.css” it loads the css as /css/style.css on public but that doesn’t open the css file.
I removed the / from the path - href = "css/style.css" That makes the homepage css to work properly but the other pages don’t.

So this doesn’t work on my end. What’s the best solution especially with the fact that other pages are suppose to also render css with …/css/style.css?

Share your project; otherwise we’re just guessing.

Yes sure. GitHub - gabadigital/

  • The code is in Partial/header.html.

I think I just figured out what you’re trying to do.

You’re trying to open public/index.html from the file system (double-clicking on the file) instead of serving it with a web server. That won’t work.

See this comment.