diff options
-rw-r--r-- | _posts/en/2025-06-18-apache_jekyll_tags.md | 39 | ||||
-rw-r--r-- | _posts/es/2025-06-18-apache_jekyll_tags.md | 42 |
2 files changed, 81 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. diff --git a/_posts/es/2025-06-18-apache_jekyll_tags.md b/_posts/es/2025-06-18-apache_jekyll_tags.md new file mode 100644 index 0000000..cde3151 --- /dev/null +++ b/_posts/es/2025-06-18-apache_jekyll_tags.md @@ -0,0 +1,42 @@ +--- +layout: post +title: "Fixing links to a jekyll-archive generated page in apache" +lang: en +date: 2025-06-18 +tags: ["Tutoriales"] +--- + +Como han podido ver, he agregado una [página para navegar entre las etiquetas](/tags) en mi página. Aunque por un par de semanas no funcionaba. + +Este será un post simple explicando cómo arreglar esto, para la posteridad. La culpa es de Apache: si revisas el directorio de tu sitio en +`/var/www/html`, verás que Jekyll genera un directorio con la siguiente estructura: + +``` +tags/ +| +|-my_tag + | + |- index.html +``` +<br> + +Así que el archivo que en realidad queremos servir cuando alguien navega a `/tags/my_tag` es `/tags/my_tag/index.html`. Jekyll usualmente enlazará +a la primera ruta en vez de a la segunda. Y esto está bien, el primer URL está más bonito y es más restful y demás que el segundo. + +Para arreglar esto en el lado de Apache, agregaremos la siguiente _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> +Eso es todo. Ejecuta `sudo systemctl reload apache2` si usas Systemd para actualizar tu sitio y éste debería enlazar correctamente a la página de +cada etiqueta. + +P.D. sí, tomé un descanso de picoshock, trabajando en él pausadamente. Espero tener algo (bueno o malo) para escribir otra entrada en el devlog la siguiente +semana. Manténganse sintonizados. |