Hi guys, I’m Hugo first-time user and I’m having a problem loading the fonts and images in production on GitHub Pages.
Right now I’m working on the index/landing layouts/index.html page and while everything works fine locally I can’t get fonts and images loaded in production cause of the 404 I’m getting due to the wrong path.
I attempted to resolve this by reviewing the documentation and community forum, but was unsuccessful. Thus, I am creating this topic.
Repository tree ![]()
├── archetypes
│ └── default.md
├── assets
│ └── sass
│ ├── base
│ │ ├── _footer.scss
│ │ ├── _header.scss
│ │ └── _main.scss
│ ├── main.scss
│ └── utils
│ ├── _breakpoints.scss
│ └── _fonts.scss
├── config
│ ├── _default
│ │ └── hugo.toml
│ └── production
│ └── hugo.toml
├── content
│ └── _index.md
├── data
├── i18n
├── layouts
│ ├── _default
│ │ ├── baseof.html
│ │ └── taxonomy.html
│ ├── index.html
│ └── partials
│ ├── dartsass.html
│ ├── footer.html
│ ├── head.html
│ └── header.html
├── node_modules
│ └── @picocss
│ └── ...
├── package-lock.json
├── package.json
├── public
├── static
│ ├── fonts
│ │ ├── ...
│ └── images
│ ├── ...
└── themes
Production config ![]()
config/production/hugo.toml
baseURL = "https://<username>.github.io/<repo-name>/"
Images path ![]()
layouts/index.html
<img src="{{ "/images/<image-name>" | relURL }}" />
Fonts path ![]()
assets/sass/main.scss
@font-face {
font-family: "Arvo";
src: url("/fonts/Arvo-Bold.eot");
src: url("/fonts/Arvo-Bold.eot?#iefix") format("embedded-opentype"),
url("/fonts/Arvo-Bold.woff2") format("woff2"),
url("/fonts/Arvo-Bold.woff") format("woff"),
url("/fonts/Arvo-Bold.ttf") format("truetype");
font-weight: bold;
font-style: normal;
font-display: swap;
}
...
Thank you.