Site.baseurl works locally but not when deployed on GHP

When I test my blog locally, the links in my post template (below) properly go to the correct URL relative to the root of my blog. However, when I deploy it, the URLs are relative to my post path, and so they end up being wrong.

The post page:
Correctly redirects to my author page:

Online, the post page: medablog/medabots/2021/07/23/New-Medawatch-Who-Dis.html
Incorrectly redirects to: medablog/medabots/2021/07/23/medablog//authors/variant.html

Here’s my post template:

layout: default
<h1 style="margin-bottom: 0">{{ page.title }}</h1>
{%- assign author = site.authors | where: "name", | first -%}
<p style="margin-bottom: 0"><small>- <a href="{{ site.baseurl }}/authors/{{ author.slug | slugify }}.html">{{ }}</a> {{ | date_to_rfc822 }}</small></p>
{{ page.content }}
<p style="margin-bottom: 0; text-align: right;"><small>Tags:{%- for tag in page.tags -%}&nbsp;<a href="{{ site.baseurl }}/tags/{{ tag | slugify }}.html">{{ tag }}</a>{%- endfor -%}</small></p>

In order to use later versions of Jekyll and my own plugins to play around with, I’ve got a GitHub Action to deploy pages from my master branch to the gh-pages branch, which is what actually gets deployed.

Here’s the repo:
The gh-pages branch:

I’m using site.baseurl everywhere, so I’m not sure why exactly my deployed page is unable to correctly parse the absolute path… Any ideas?

its kinda like you did the baseurl wrong in the config - with the slash at the end instead of the beginning.

Your rendered link is <a href="medablog//authors/variant.html"> which is wrong - there is no leading slash - which tells the server to start at the root - and then there are 2 slashes after medablog.

From what I can tell your config is correct and this should not be happening, which makes me think your action has an issue. Did you at one point have the baseurl slash at the end?

ah - in your action I think you have: bundle exec jekyll build --baseurl="medablog/" -d build which is incorrect - slash needs to be first not last.

1 Like

not sure why you are specifying the baseurl in the command - seems unneccassry but I have not used actions so could easily be wrong. But doing that there when you also have it in the config is going to make troubleshooting stuff like this hard!


Ah. I totally missed that. Thanks so much.

1 Like