I am trying to set up a personal homepage with Jekyll using the domain provided by my University.
An issue that I have not been able to resolve is Jekyll forcing me to use absolute paths which I believe are not compatible with the webpage hosting service.
The _config.yml file determines how Jekyll generates linkings in the index.html file which is the homepage. _config.yml looks like this...
title: Homepage | Ishank Juneja
email: ishankjuneja@gmail.com
description: >- # this means to ignore newlines until "baseurl:"
Personal homepage Beta version
baseurl: "foobar" # the subpath of your
site, e.g. /blog
url: "http://home.iitb.ac.in/~ishankjuneja" # the base hostname & protocol for your site, e.g.
http://example.com
twitter_username: ishankjuneja
github_username: ishank-juneja
# Build settings
markdown: kramdown
theme: minima
plugins:
- jekyll-feed
An example of the (many) linkings it generates in the index.html file is
<link rel="stylesheet" href="/foobar/assets/main.css">
This link explained to me that this is, in fact, an absolute path, which didn't seem like a problem to me, but the Directory Tree on the Web hosting service looks like,
public_html
├── 404.html
├── about
│ └── index.html
├── assets
│ ├── main.css
│ └── minima-social-icons.svg
├── feed.xml
├── index.html
└── jekyll
└── update
└── 2018
└── 10
└── 04
└── test-post.html
The URL for my homepage http://home.iitb.ac.in/~ishankjuneja/
is associated with the folder public_html
, so the path for main.css above would be incorrect. Something like href="assets/main.css"
works well, but there seems to be nothing that I can type in _config.yml
to get this result.
In configuration you have to properly set up baseurl:
baseurl: "~ishankjuneja"
Then use
{{site.baseurl}}page.url
In your example , putting /foobar (the baseurl in _config.yml) is not a good idea.
Using absolute URl is not a good idea either as you have said.
The solution is to use relative_url Liquid Filter as
<link rel="stylesheet" href={{"/assets/main.css" | relative_url }} >
similar solution as @Aleksandr Kiselev suggested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With