From 6aac3f95fecf067791086a5510513f1c5a2f4c3f Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Thu, 2 Jan 2020 07:26:23 +0800 Subject: [PATCH] Important: Fixed sitemap template. --- 404.html | 15 +++++++-------- _config.yml | 22 +++++++++++++--------- sitemap.xml | 26 +++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/404.html b/404.html index bf20d63..b5d3db5 100644 --- a/404.html +++ b/404.html @@ -4,16 +4,15 @@ # MIT License layout: page title: "404: Page not found" - permalink: /404.html -redirect_from: # Same as site.blocklist -- /norobots/ -- /assets/ -- /tabs/ -- /categories/ -- /tags/ -- /posts/ +redirect_from: # part of site.sitemap_exclude + - /norobots/ + - /assets/ + - /tabs/ + - /categories/ + - /tags/ + - /posts/ dynamic_title: true --- diff --git a/_config.yml b/_config.yml index df97e00..276a5e1 100644 --- a/_config.yml +++ b/_config.yml @@ -160,12 +160,16 @@ exclude: - tools sitemap_exclude: # Sitemap will exclude the following items. - - /norobots/ - - /assets/ - - /tabs/ - - /categories/ - - /tags/ - - /posts/ - - /404.html - - /redirects.json - - /search.json + fuzzy: + - /assets/ + accurate: + - /norobots/ + - /tabs/ + - /categories/ + - /tags/ + - /posts/ + - 404.html + - feed.xml + - sitemap.xml + - robots.txt + - redirects.json diff --git a/sitemap.xml b/sitemap.xml index d7390ed..0fe8545 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -1,5 +1,6 @@ --- layout: compress +# # The Sitemap template # © 2017-2019 Cotes Chung # MIT License @@ -41,7 +42,30 @@ layout: compress {% 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 %} {% endif %}