From ce7f8f9c3d3cfe0704e4b3d79a03b92ffba9aac3 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Wed, 18 Jun 2025 19:32:09 -0600 Subject: Add apache jekyll tags article --- _posts/en/2025-06-18-apache_jekyll_tags.md | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 _posts/en/2025-06-18-apache_jekyll_tags.md (limited to '_posts/en') diff --git a/_posts/en/2025-06-18-apache_jekyll_tags.md b/_posts/en/2025-06-18-apache_jekyll_tags.md new file mode 100644 index 0000000..021fd1e --- /dev/null +++ b/_posts/en/2025-06-18-apache_jekyll_tags.md @@ -0,0 +1,39 @@ +--- +layout: post +title: "Fixing links to a jekyll-archive generated page in apache" +lang: en +date: 2025-06-18 +tags: ["Tutorials"] +--- + +As you can see, I've added a [page for navigating tags](/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: + +```apache + +# Your site's config... + RewriteEngine On + # Perhaps some other rules... + RewriteRule ^/tags/(.+)$ %{DOCUMENT_ROOT}/tags/$1/index.html + # The rest of your config. + +``` +
+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. -- cgit v1.2.3