I’ve had my blog on github for a Jekyll. Out of nowhere, when I drill into a post, the formatting of the post is not right.
Any suggestions on what to tweak to get it back to it’s defaults?
https://dfinke.github.io/ https://github.com/dfinke/dfinke.github.io
I think this issue explains the problem and solution. Basically baseurl
is always the empty string on Github, so all URLs in head.html
need to be absolute:
https://github.com/github/pages-gem/issues/460
Thank you, this solved some of the issues. I’m a noob in this space, is there a script, migration or a way to update my existing blog that fixes this?
The issue I mentioned references Parker’s post that gives a good explanation of how baseurl
and url
work (note that the post predates the relative_url
/absolue_url
filters).
To fix your site, you should set basurl
to the empty string in _config.yml
:
baseurl: ''
Then change all your site-relative-path-relative URLs to site-relative-path-absolute URLs (and optionally switch to relative_url
). For example:
<link rel="stylesheet" href="{{ "css/main.css" | prepend: site.baseurl }}">
to:
<link rel="stylesheet" href="{{ "/css/main.css" | relative_url }}">
Note that you are not required to use baseurl
and relative_url
– it is only there to help when you need to move a site to a different location (e.g. from example.com
to example.com/blog
). For a site at the root, relative_url
will always be a no-op.
For RSS feeds, you should use absolute URL everywhere (generated with absolute_url
). Be sure to test any changes with the RSS Feed Validator.
Looking more closely, it appears your blog uses a copy of the Jekyll-Uno theme from 2016.
Unfortunately, at that time the Uno theme had a bug in its baseurl
setup. The bug (issue #56) was found and fixed in August by this commit:
https://github.com/joshgerdes/jekyll-uno/commit/26c1b3ce9a68d2d9280c58f8cb985cb289c12fd9
You could probably cherry-pick that commit or better, merge all the changes from the last year so that your theme is up to date.
Thank you for tracking that down.