Important: Fixed sitemap template.
This commit is contained in:
parent
3e004d1bf3
commit
6aac3f95fe
3 changed files with 45 additions and 18 deletions
15
404.html
15
404.html
|
@ -4,16 +4,15 @@
|
||||||
# MIT License
|
# MIT License
|
||||||
layout: page
|
layout: page
|
||||||
title: "404: Page not found"
|
title: "404: Page not found"
|
||||||
|
|
||||||
permalink: /404.html
|
permalink: /404.html
|
||||||
|
|
||||||
redirect_from: # Same as site.blocklist
|
redirect_from: # part of site.sitemap_exclude
|
||||||
- /norobots/
|
- /norobots/
|
||||||
- /assets/
|
- /assets/
|
||||||
- /tabs/
|
- /tabs/
|
||||||
- /categories/
|
- /categories/
|
||||||
- /tags/
|
- /tags/
|
||||||
- /posts/
|
- /posts/
|
||||||
|
|
||||||
dynamic_title: true
|
dynamic_title: true
|
||||||
---
|
---
|
||||||
|
|
22
_config.yml
22
_config.yml
|
@ -160,12 +160,16 @@ exclude:
|
||||||
- tools
|
- tools
|
||||||
|
|
||||||
sitemap_exclude: # Sitemap will exclude the following items.
|
sitemap_exclude: # Sitemap will exclude the following items.
|
||||||
- /norobots/
|
fuzzy:
|
||||||
- /assets/
|
- /assets/
|
||||||
- /tabs/
|
accurate:
|
||||||
- /categories/
|
- /norobots/
|
||||||
- /tags/
|
- /tabs/
|
||||||
- /posts/
|
- /categories/
|
||||||
- /404.html
|
- /tags/
|
||||||
- /redirects.json
|
- /posts/
|
||||||
- /search.json
|
- 404.html
|
||||||
|
- feed.xml
|
||||||
|
- sitemap.xml
|
||||||
|
- robots.txt
|
||||||
|
- redirects.json
|
||||||
|
|
26
sitemap.xml
26
sitemap.xml
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
layout: compress
|
layout: compress
|
||||||
|
#
|
||||||
# The Sitemap template
|
# The Sitemap template
|
||||||
# © 2017-2019 Cotes Chung
|
# © 2017-2019 Cotes Chung
|
||||||
# MIT License
|
# MIT License
|
||||||
|
@ -41,7 +42,30 @@ layout: compress
|
||||||
|
|
||||||
{% for page in site.pages %}
|
{% for page in site.pages %}
|
||||||
|
|
||||||
{% if site.sitemap_exclude contains page.url %}
|
{% assign pass = false %}
|
||||||
|
|
||||||
|
{% for fuzzy in site.sitemap_exclude.fuzzy %}
|
||||||
|
{% if page.url contains fuzzy %}
|
||||||
|
{% assign pass = true %}
|
||||||
|
{% break %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% unless pass %}
|
||||||
|
{% for accurate in site.sitemap_exclude.accurate %}
|
||||||
|
{% assign len = accurate | size %}
|
||||||
|
{% capture beg %}{{ 0 | minus: len }}{% endcapture %}
|
||||||
|
{% capture tail %}{{ page.url | slice: beg, len }}{% endcapture %}
|
||||||
|
|
||||||
|
{% if tail == accurate %}
|
||||||
|
{% assign pass = true %}
|
||||||
|
{% break %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
{% endunless %}
|
||||||
|
|
||||||
|
{% if pass %}
|
||||||
{% continue %}
|
{% continue %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue