5

I'm creating a GitHub project page with Jekyll.

I've read the previous questions on this subject, as well as the Jekyll documentation here.

I've tried setting baseurl in _config.yml to both /my-project and http://myaccount.github.io/my-project while linking my CSS and js files like so:

<script src="{{ site.baseurl }}/js/javascript.js"></script>
<link href="{{ site.baseurl }}/css/style.css" rel="stylesheet">

When I run jekyll --serve --baseurl '' everything looks good on localhost.

But when I push to github, all of my CSS and js files are 404ing; the links are getting turned into http://css/style.css and so on.

What am I missing here?

I'm also confused about the purpose of the BASE_PATH variable in _config.yml, as opposed to baseurl.

I tried setting BASE_PATH and linking my files that way, but that didn't work either.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
resistorsings
  • 111
  • 1
  • 2
  • 5

5 Answers5

2

I figured it out -- baseurl wasn't getting parsed because I had mistakenly placed it under the JB: hash in _config.yml. I moved baseurl to a different part of the file and it's working properly now.

resistorsings
  • 111
  • 1
  • 2
  • 5
1

try using baseurl instead. That's what I use.

see https://jekyllrb.com/docs/configuration/default/

Harry Moreno
  • 10,231
  • 7
  • 64
  • 116
  • Do you mean {{ site.url}} instead of {{ site.baseurl}} to get the baseurl in Jekyll? Not working. I want to get the name of localhost in my local and tik9.github.io in my remote env. – Timo Feb 10 '21 at 19:18
  • 1
    looks like the api has changed since I wrote that. `baseurl` should be it. You are editing the `_config.yml` file? – Harry Moreno Feb 10 '21 at 19:56
  • No, I want to have the hostname, in php: gethostname(); – Timo Feb 12 '21 at 19:53
0

You can try and create a new variable in the config file,

newbaseurl: /

and use it instead of baseurl, this seemed to fix my issues.

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
0

I fixed a similar issue by changing site.baseurl to relative_url as per: Jekyll site works locally but not on Github Pages

Trying newbaseurl: / did not work for me.

naaman
  • 900
  • 10
  • 15
-1

I had a same issue and I created a new variable in inside _config.yml

resource: https://name.github.io/myapp

Then I used that variable like this

<link rel="stylesheet" href="{{ "/style.css"  | prepend:site.resource}}">

Also please remember to build before push to the remote. Run this to build

jekyll build
Ishan Fernando
  • 2,758
  • 1
  • 31
  • 38