Search code examples
jekyllassetsgithub-pagesjekyll-theme

jekyll GitHub Page page not loading assets


I have a GitHub hosted https://waltershub.github.io the repo is https://github.com/waltershub/waltershub.github.io

The site builds properly locally with all assets and css but on the hosted version none of it shows

The errors in console are:

[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (font-awesome.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (dark.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (function.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (walt.jpg, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (walt.jpg, line 0)

I have validated the YAML and it is good


Solution

  • In _config.yml you are using a baseurl of webpage:

    baseurl: "/webpage" # the subpath of your site, e.g. /blog
    

    When according to your setup should be '':

    baseurl: ""
    

    Then the part that load assets:

    <link rel="stylesheet" href="{{ "/assets/fonts/font-awesome/css/font-awesome.css" | prepend: site.baseurl }}">
    <link rel="stylesheet" href="{{site.baseurl}}/assets/stylesheets/{% if site.blog_theme == "light" %}light.css{% else %}dark.css{% endif %}">
    

    Will properly generate the urls like:

    <link rel="stylesheet" href="/assets/fonts/font-awesome/css/font-awesome.css">
    <link rel="stylesheet" href="/assets/stylesheets/dark.css">
    

    Tnstead of the wrong:

    <link rel="stylesheet" href="/webpage/assets/fonts/font-awesome/css/font-awesome.css">
    <link rel="stylesheet" href="/webpage/assets/stylesheets/dark.css">