Some directories are not available in /assets

Hello, I have two directories in /assets dir:

assets/
├── css/
│   └── theme-dark.css
└── fonts/
    └── icomoon.eot

And I can access:

http://localhost:1313/eui/css/theme-dark.css

But I can’t access:

http://localhost:1313/eui/fonts/icomoon.eot

Can someone explain why?
Is there some kind of blacklist for directories?
I did not found that info in docs about resources.

I’m not using any special mounts in hugo.toml.
I’m using hugo-relearn theme.

Whatever is in assets needs to be processed by one of the resources methods. Check out the chapter on pipes in the documentation.

So I need to put them in /static directory?
Can I get rid of absoulte url then?

src: url(/eui/fonts/icomoon.woff)

To make it look like this?

src: url(fonts/icomoon.woff)

That’s not what I said:

You can also just leave them where they are and .Publish them.

That’s a question about the content of your CSS. Where a relative URL is always relative to the location of the CSS.

That’s a question about the content of your CSS. Where a relative URL is always relative to the location of the CSS.

Its the style in the custom-header for every page so amount of ../ will be different for every page.

Is there a way to omit the first part?

../fonts/icomoon.woff
../../fonts/icomoon.woff
../../../fonts/icomoon.woff

Please read carefully. In the CSS

So, the reference to the fonts does not depend on the location of the HTML, but only on the location of the CSS.
With this setup

── css
│   ├── prism.css
│   └── syntax.css
main.css
...
├── fonts
│   ├── OptimaLTPro-DemiBold.woff2
│   ├── archivo-narrow-v21-latin-700.woff
│   ├── archivo-narrow-v21-latin-700.woff2
│   ├── archivo-narrow-v21-latin-regular.woff
│   ├── archivo-narrow-v21-latin-regular.woff2

main.css will refer to the first font as url(fonts/OptimaLTPro-DemiBold.woff2). On every page. And prism.css will refer to the same font as url(../fonts/OptimaLTPro-DemiBold.woff). On every page.

If you use inline styles referring to the fonts, all bets are off, of course. Just don’t do that.

All that has nothing to do with Hugo, BTW.

If you use that simple without processing you could

Assuming your baseurl is https://www.example.com/eui/

Place them in your static folder

/static/style.css
/static/fonts/font1.woff2
  • style as

       <link rel="stylesheet" href="{{- absURL "style.css" -}}" />
    
  • And in the style.css

    src: url('fonts/font1.woff2')
    
1 Like

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