As you can see, I’ve added a page for navigating tags on my site. For a couple of weeks it was broken though.
This will be a simple post explaining how to fix this for posterity. Apache is at fault here: if you check your site’s directory in /var/www/html
,
you’ll see that Jekyll generates a directory with the following structure:
tags/
|
|-my_tag
|
|- index.html
So the file we actually want to serve when someone navigates to /tags/my_tag
is /tags/my_tag/index.html
. Jekyll will usually link to the first
route instead of the second one. And this is okay, the first URL is prettier and more restful and yadda-yadda than the second one.
To fix this on Apache’s side, we’ll add the following rewrite rule:
<VirtualHost _default_:443>
# Your site's config...
RewriteEngine On
# Perhaps some other rules...
RewriteRule ^/tags/(.+)$ %{DOCUMENT_ROOT}/tags/$1/index.html
# The rest of your config.
</VirtualHost>
That’s it. Run sudo systemctl reload apache2
if you’re on Systemd to update your site and it should link correctly to every tag’s page.
P.S. yes, I took a rest of sorts on picoshock, working on it on and off. I hope I can have something (good or bad) to show for it the next week. Stay tuned.