Yes the code by author is wrong and you should fix it. Removing a forward slash on most URLs anywhere in the URL (ie beginning and middle and end) is very weird and not something that Jekyll sites do.
It might work fine if all your pages are at the same level, but as it will break otherwise.
For example
Given you are on page
/a/b/c.html
And you want to link to
/a/d.html
If your URL is this without any forwardslash it will break.
ad.html
Firstly, it will be a relative URL as ./ad.html
Which means from c.html it will link to
/a/b/c.html/ad.html
Secondly, the / between a
and d
is important.
Doing this works from anywhere on the site because it is absolute and not relative.
href="/a/d.html"
And if you use relative_url
then that will prepend /repo-name
, which is needed on GH Pages.
The absolute URL is especially important for assets. As you need to access /css/styles.css
an absolute URL from anywhere. If it was css/styles.css
in the HTML then the browser would see it as /a/b/c.html/css/styles.css
for example.