summaryrefslogtreecommitdiff
path: root/_posts/en
diff options
context:
space:
mode:
Diffstat (limited to '_posts/en')
-rw-r--r--_posts/en/2025-06-18-apache_jekyll_tags.md39
1 files changed, 39 insertions, 0 deletions
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
+```
+<br>
+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
+<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>
+```
+<br>
+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.