Merge pull request #85 from madrilene/fix-redirects

redirects same line, use in example post
This commit is contained in:
Lene Saile 2025-03-07 17:58:18 +01:00 committed by GitHub
commit cf7988da3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 9 deletions

View file

@ -3,12 +3,10 @@ permalink: /_redirects
eleventyExcludeFromCollections: true eleventyExcludeFromCollections: true
excludeFromSitemap: true excludeFromSitemap: true
--- ---
{%- for page in collections.all -%}
{% for page in collections.all %} {%- if page.url and page.data.redirectFrom -%}
{% if page.url and page.data.redirectFrom %} {%- for oldUrl in page.data.redirectFrom %}
{% for oldUrl in page.data.redirectFrom %} {{ oldUrl }} {{ page.url }}
{{ oldUrl }} {%- endfor %}
{{ page.url }} {%- endif -%}
{% endfor %} {%- endfor -%}
{% endif %}
{% endfor %}

View file

@ -3,6 +3,7 @@ title: 'Post with 301 redirects'
description: 'A 301 is used when a page has permanently changed location. Informing about this change is indispensable if you want to keep a positioning. Aleksandr Hovhannisyan came up with an elegant solution for Eleventy and Netlify.' description: 'A 301 is used when a page has permanently changed location. Informing about this change is indispensable if you want to keep a positioning. Aleksandr Hovhannisyan came up with an elegant solution for Eleventy and Netlify.'
date: 2022-08-28 date: 2022-08-28
tags: ['redirects', 'feature'] tags: ['redirects', 'feature']
redirectFrom: ['/old-route/', '/optionally-another-old-route/']
--- ---
URLs usually change over time, as you use another CMS or optimize your file structure. URLs usually change over time, as you use another CMS or optimize your file structure.