Css for layouts/index.html

I’m creating a simple site where the landing page is mine own and on it will be a link to the list template blog generated by Hugo. Watching a tutorial I created index.html in the layouts folder to create my special landing homepage but I can’t seem to link any css file to it. I’ve tried putting the css file everywhere but it doesn’t pick it up

Where is “everywhere” and how are you linking to it?

Please have a read about Requesting Help to see how to make it easier for us to help you.

<link rel="stylesheet" href="../static/styles.css" />

And the CSS file is there, I’ve also tried putting it in public/assets/css and linked it from there but it doesnt load

Files under your /static/ folder are rendered as-is under your site root.

So /static/foo/bar/baz.css will be found at yoursite.com/foo/bar/baz.css

Docs: Static Files | Hugo

place your css in assets/css folder. then call it like this

{{ $styles := resources.Get "css/style.css" | minify }}
<link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen">

This worked for me, thank you.
Also, is putting the css file in the /static/ folder normal file structure convention or is there some other place I should put it?

If you don’t need to do anything to it, it’s fine to put it under /static/. If however you wanted to do some other things, such as minifying, fingerprinting, etc [see docs: Hugo Pipes Introduction | Hugo ] then you would put it under /assets/ instead.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.