[SOLVED] Hugo use my personal style only on certain condition

Hello,

I have a hugo project with 2 different stylesheet : bootstrap.min.css and style.css

I use them in a partial head.html :

<meta ...>
....
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/header.css" /> 
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/style.css" />

I include it in my templates with the partial function. {{ partial "head.html" . }}.

When I run hugo server -D I face a very strange bug :

  • When I’m in my code editor and I save ctrl+s my project on my style.css file, my style is interpreted and everything is ok
  • When I’m on an other file, for example the template of the page single.html and I save ctrl+s my project, my style is NOT interpreted.

I seriously don’t understand how it can be possible.

I’d recommand using absURL or relURL rather than your current implementation

<link rel="stylesheet" href="{{ "/css/header.css" | absURL }}" /> 

my style is NOT interpreted.

What do you mean by that?

I can’t put 2 images in the same post at the moment but when my style is interpreted I have two line with 4 boxes.

And when my style isn’t I have that :

That’s what I mean by “my style is not Interpreted”.

I tried your solution and it didn’t change anything.
But I found something strange in Chrome debugger :

When it doesn’t work here is my link balise <link rel="stylesheet" href="http://localhost:1313/css/style.css">

When it works here is my link balise <link rel="stylesheet" href="http://localhost:1313/css/style.css?livereload=1533648105215">

This livereload paramater seems to be the reason it works or not…

Ok so I used this topic and found the solution to my problem : https://discourse.gohugo.io/t/cs

It seems that it was due to some cache.

Here is the keystroke for a hard browser refresh on chrome Ctrl + shift + R !