Skip to content

Commit dd2aa62

Browse files
committed
Important: Fixed sitemap template.
1 parent 94fb36b commit dd2aa62

File tree

3 files changed

+45
-18
lines changed

3 files changed

+45
-18
lines changed

404.html

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
# MIT License
55
layout: page
66
title: "404: Page not found"
7-
87
permalink: /404.html
98

10-
redirect_from: # Same as site.blocklist
11-
- /norobots/
12-
- /assets/
13-
- /tabs/
14-
- /categories/
15-
- /tags/
16-
- /posts/
9+
redirect_from: # part of site.sitemap_exclude
10+
- /norobots/
11+
- /assets/
12+
- /tabs/
13+
- /categories/
14+
- /tags/
15+
- /posts/
1716

1817
dynamic_title: true
1918
---

_config.yml

+13-9
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,16 @@ exclude:
160160
- tools
161161

162162
sitemap_exclude: # Sitemap will exclude the following items.
163-
- /norobots/
164-
- /assets/
165-
- /tabs/
166-
- /categories/
167-
- /tags/
168-
- /posts/
169-
- /404.html
170-
- /redirects.json
171-
- /search.json
163+
fuzzy:
164+
- /assets/
165+
accurate:
166+
- /norobots/
167+
- /tabs/
168+
- /categories/
169+
- /tags/
170+
- /posts/
171+
- 404.html
172+
- feed.xml
173+
- sitemap.xml
174+
- robots.txt
175+
- redirects.json

sitemap.xml

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
layout: compress
3+
#
34
# The Sitemap template
45
# © 2017-2019 Cotes Chung
56
# MIT License
@@ -41,7 +42,30 @@ layout: compress
4142

4243
{% for page in site.pages %}
4344

44-
{% if site.sitemap_exclude contains page.url %}
45+
{% assign pass = false %}
46+
47+
{% for fuzzy in site.sitemap_exclude.fuzzy %}
48+
{% if page.url contains fuzzy %}
49+
{% assign pass = true %}
50+
{% break %}
51+
{% endif %}
52+
{% endfor %}
53+
54+
{% unless pass %}
55+
{% for accurate in site.sitemap_exclude.accurate %}
56+
{% assign len = accurate | size %}
57+
{% capture beg %}{{ 0 | minus: len }}{% endcapture %}
58+
{% capture tail %}{{ page.url | slice: beg, len }}{% endcapture %}
59+
60+
{% if tail == accurate %}
61+
{% assign pass = true %}
62+
{% break %}
63+
{% endif %}
64+
65+
{% endfor %}
66+
{% endunless %}
67+
68+
{% if pass %}
4569
{% continue %}
4670
{% endif %}
4771

0 commit comments

Comments
 (0)