Skip to content

Commit 7a57d97

Browse files
committed
Fix sitemap.xml: Exclude redirected links
1 parent 9545ab6 commit 7a57d97

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sitemap.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ layout: null
44

55
<?xml version="1.0" encoding="UTF-8"?>
66
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
7+
{% assign redirect_links = site.pages | concat: site.posts | map: 'redirect_from' | compact | flatten %}
8+
79
{% for page in site.pages %}
810
{% if page.url contains '.html' or page.url contains '/' %}
9-
{% unless page.sitemap_exclude or page.url contains '404.html' or page.url contains '.xml' or page.url contains '.css'%}
11+
{% unless redirect_links contains page.url or page.sitemap_exclude or page.url contains '404.html' or page.url contains '.xml' or page.url contains '.css'%}
1012
<url>
1113
<loc>{{ site.url }}{{ page.url | remove: 'index.html' | remove: '.html' }}</loc>
1214
<lastmod>{{ page.date-modified | default: site.default-date-modified | date: '%Y-%m-%d' }}</lastmod>

0 commit comments

Comments
 (0)