Static files not loading

I am trying to load local fonts stored in /static, but it seems to not being loading any of the static files. I have the files in /static, and I can see them when I look in /public (the files Hugo generates). I just don’t know why it isn’t loading the files. If you want to look at the repo, I have it on GitHub on the local-fonts branch.

Here is the console log, but it doesn’t give much info except that it can’t find the files.

GET
http://localhost:1313/favicon.ico
[HTTP/1.1 404 Not Found 0ms]

GET
http://localhost:1313/fonts/inter-v18-cyrillic_cyrillic-ext_greek_greek-ext_latin_latin-ext_vietnamese-regular.woff2
[HTTP/1.1 404 Not Found 0ms]

GET
http://localhost:1313/fonts/inter-v18-cyrillic_cyrillic-ext_greek_greek-ext_latin_latin-ext_vietnamese-700.woff2
[HTTP/1.1 404 Not Found 0ms]

downloadable font: download failed (font-family: "Inter" style:normal weight:400 stretch:100 src index:0): status=2147746065 source: http://localhost:1313/fonts/inter-v18-cyrillic_cyrillic-ext_greek_greek-ext_latin_latin-ext_vietnamese-regular.woff2
downloadable font: download failed (font-family: "Inter" style:normal weight:700 stretch:100 src index:0): status=2147746065 source: http://localhost:1313/fonts/inter-v18-cyrillic_cyrillic-ext_greek_greek-ext_latin_latin-ext_vietnamese-700.woff2
GET
http://localhost:1313/fonts/roboto-v47-cyrillic_cyrillic-ext_greek_greek-ext_latin_latin-ext_vietnamese-regular.woff2
[HTTP/1.1 404 Not Found 0ms]

downloadable font: download failed (font-family: "Roboto" style:normal weight:400 stretch:100 src index:0): status=2147746065 source: http://localhost:1313/fonts/roboto-v47-cyrillic_cyrillic-ext_greek_greek-ext_latin_latin-ext_vietnamese-regular.woff2 

Any help is appreciated.

Because your website is in subfolder

when it load:

Web Server is available at http://localhost:1313/moonwalk/ (bind address 127.0.0.1)

so your favicon is in http://localhost:1313/moonwalk/favicon.ico

Your config got:

baseURL = 'https://arkhamcookie.github.io/moonwalk/'

change to

baseURL = 'https://arkhamcookie.github.io'

will change to:

Web Server is available at http://localhost:1313/ (bind address 127.0.0.1) 
1 Like

Thank you! I knew it would be some simple user error like this. That fixed it right away.

ps. instead changing Title to [SOLVED] tick relevant button under my post. :slight_smile:

1 Like

Done! Do you happen to know if there is a way to change the baseURL using the commandline? Because when running it on GitHub pages, I need it to be the old baseURL.

hugo server help tells you all about that

1 Like

Ah, thanks. Should have checked that first, my bad.

Also I think you mean hugo help server.

Sorry if this is a dumb question, but what url should I put as the baseURL in --baseURL? Should it be localhost?

Indeed

You don’t need that parameter if you’re running hugo server locally, usually. It’s needed if you want to access hugo server from other devices on your network. Eg, you run hugo server on your Linux box and want to access it via WLAN from your iPhone. Then you set --baseURL to http://192.168.44.xx:port, for example.

You should, however, not run server to server pages in production. Which seems what you’re planning to do. baseURL in your config must be set to the base URL of your site

1 Like

Not a must but best practice. If you do so, you get the same experience browsing locally (hugo-server) and published (hugo). Makes spotting and solving errors much easier and on the long run will save you time.

→ Keep same the same as @chrillek said.

For special use cases, like testing if your code works with and without subfolder, you may use --baseURL to override.

It seems like you want to publish your site using “GitHub Pages”. This means publishing to a subfolder.

→ in that case use the baseURL with subfolder: https://arkhamcookie.github.io/moonwalk-hugo/


missing fonts: the path in the CSS file is relative to the CSS not the base of your site. in your current main branch “../fonts/…” should work.


ignore if that’s a comment on the wrong track, BUT it seems you are creating a theme.

  • will be usually imported to /themes/moonwalk-hugo by content sides.
  • Holding all the layouts and stuff needed but no content.
  • documentation/Showcasing usually is done with an exampleSite subfolder in the theme referencing the theme.
  • a theme should work for both, with or without subfolder. you will have to test both baseURLs
1 Like

Hint:

you have two active Workflows in your repo. Guess you want to disable or delete pages build and deployment which actually calls Jekyll

1 Like

Thanks I thought I removed the Jekyll from there but it must have slipped through the cracks.

You are correct, I am looking to make this a theme. I will move the content over to the exampleSite/. Should I move the data/ files over to exampleSite/ or keep it where it is?

depends. if you have data that is used by the theme move it to the theme. if it’s part of the site content move it to exampleSite

1 Like

Sorry again for all the questions, but I was wondering if you know of a repo that using GitHub Pages and exampleSite/ that I could refer to? All the ones I have looked at so far use something else for hosting or don’t have it in exampleSite/ like you should.

right from the bat:

assuming all your theme stuff is in your repo-root. And you have an exampleSite folder holding your showcase incl. the sites hugo.toml.

your github wf shiuld just do something like:

  • checkout
  • cd exampleSite
  • hugo -- themesDir ..

result will be in exampleSite/public

  • make sure the pack and publish uses that folder

but all that is a a different topic. In case of new problems open a new topic.

1 Like

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