Generate sitemap by plugin
This commit is contained in:
parent
8909438267
commit
4ea320b250
6 changed files with 8 additions and 110 deletions
1
Gemfile
1
Gemfile
|
@ -8,6 +8,7 @@ group :jekyll_plugins do
|
||||||
gem "jekyll-redirect-from"
|
gem "jekyll-redirect-from"
|
||||||
gem "jekyll-seo-tag", "~> 2.6.1"
|
gem "jekyll-seo-tag", "~> 2.6.1"
|
||||||
gem "jekyll-archives"
|
gem "jekyll-archives"
|
||||||
|
gem "jekyll-sitemap"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
|
20
_config.yml
20
_config.yml
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
# jekyll-seo-tag settings › https://github.com/jekyll/jekyll-seo-tag/blob/master/docs/usage.md
|
# jekyll-seo-tag settings › https://github.com/jekyll/jekyll-seo-tag/blob/master/docs/usage.md
|
||||||
#--------------------------
|
#--------------------------
|
||||||
|
|
||||||
title: Chirpy # the main title
|
title: Chirpy # the main title
|
||||||
|
|
||||||
tagline: A text-focused Jekyll theme. # it will display as the sub-title
|
tagline: A text-focused Jekyll theme. # it will display as the sub-title
|
||||||
|
@ -42,7 +41,6 @@ social:
|
||||||
# - https://www.linkedin.com/in/username
|
# - https://www.linkedin.com/in/username
|
||||||
|
|
||||||
google_site_verification: google_meta_tag_verification # change to your verification string
|
google_site_verification: google_meta_tag_verification # change to your verification string
|
||||||
|
|
||||||
#--------------------------
|
#--------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,7 +182,7 @@ compress_html:
|
||||||
envs: []
|
envs: []
|
||||||
|
|
||||||
exclude:
|
exclude:
|
||||||
- vendor # Avoid Jekyll mistakenly read the vendor directory on Travis-CI's VM .
|
- vendor
|
||||||
- Gemfile.lock
|
- Gemfile.lock
|
||||||
- Gemfile
|
- Gemfile
|
||||||
- tools
|
- tools
|
||||||
|
@ -192,22 +190,6 @@ exclude:
|
||||||
- README.md
|
- README.md
|
||||||
- LICENSE
|
- LICENSE
|
||||||
|
|
||||||
sitemap_exclude: # Sitemap will exclude the following items.
|
|
||||||
fuzzy:
|
|
||||||
- /assets/
|
|
||||||
accurate:
|
|
||||||
- /norobots/
|
|
||||||
- /tabs/
|
|
||||||
- /categories/
|
|
||||||
- /tags/
|
|
||||||
- /posts/
|
|
||||||
- 404.html
|
|
||||||
- feed.xml
|
|
||||||
- sitemap.xml
|
|
||||||
- robots.txt
|
|
||||||
- redirects.json
|
|
||||||
|
|
||||||
# see: <https://github.com/jekyll/jekyll-archives/blob/master/docs/configuration.md>
|
|
||||||
jekyll-archives:
|
jekyll-archives:
|
||||||
enabled: [categories, tags]
|
enabled: [categories, tags]
|
||||||
layouts:
|
layouts:
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
{% assign all_list = "" | split: "" %}
|
{% assign all_list = "" | split: "" %}
|
||||||
|
|
||||||
{% for post in site.posts %}
|
{% for post in site.posts %}
|
||||||
{% if post.lastmod %}
|
{% if post.last_modified_at %}
|
||||||
{% capture elem %}
|
{% capture elem %}
|
||||||
{{- post.lastmod | date: "%Y%m%d%H%M%S" -}}::{{- forloop.index0 -}}
|
{{- post.last_modified_at | date: "%Y%m%d%H%M%S" -}}::{{- forloop.index0 -}}
|
||||||
{% endcapture %}
|
{% endcapture %}
|
||||||
{% assign all_list = all_list | push: elem %}
|
{% assign all_list = all_list | push: elem %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -31,10 +31,10 @@ layout: default
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- lastmod -->
|
<!-- lastmod -->
|
||||||
{% if page.lastmod %}
|
{% if page.last_modified_at %}
|
||||||
<div>
|
<div>
|
||||||
Updated
|
Updated
|
||||||
{% include timeago.html date=page.lastmod class="lastmod" tooltip=true %}
|
{% include timeago.html date=page.last_modified_at class="lastmod" tooltip=true %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ Jekyll::Hooks.register :posts, :post_init do |post|
|
||||||
|
|
||||||
if commit_num.to_i > 1
|
if commit_num.to_i > 1
|
||||||
lastmod_date = `git log -1 --pretty="%ad" --date=iso "#{ post.path }"`
|
lastmod_date = `git log -1 --pretty="%ad" --date=iso "#{ post.path }"`
|
||||||
post.data['lastmod'] = lastmod_date
|
post.data['last_modified_at'] = lastmod_date
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
85
sitemap.xml
85
sitemap.xml
|
@ -1,85 +0,0 @@
|
||||||
---
|
|
||||||
layout: compress
|
|
||||||
|
|
||||||
# The Sitemap template
|
|
||||||
# v2.0
|
|
||||||
# https://github.com/cotes2020/jekyll-theme-chirpy
|
|
||||||
# © 2017-2019 Cotes Chung
|
|
||||||
# MIT License
|
|
||||||
---
|
|
||||||
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
||||||
|
|
||||||
{% for post in site.posts %}
|
|
||||||
<url>
|
|
||||||
<loc>{{ site.url | append: site.baseurl | append: post.url }}</loc>
|
|
||||||
{% if post.lastmod %}
|
|
||||||
<lastmod>{{ post.lastmod | date_to_xmlschema }}</lastmod>
|
|
||||||
{% else %}
|
|
||||||
<lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if post.sitemap.changefreq %}
|
|
||||||
<changefreq>{{ post.sitemap.changefreq }}</changefreq>
|
|
||||||
{% else %}
|
|
||||||
<changefreq>monthly</changefreq>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if post.sitemap.priority %}
|
|
||||||
<priority>{{ post.sitemap.priority }}</priority>
|
|
||||||
{% else %}
|
|
||||||
<priority>0.5</priority>
|
|
||||||
{% endif %}
|
|
||||||
</url>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% for page in site.pages %}
|
|
||||||
|
|
||||||
{% 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 %}
|
|
||||||
|
|
||||||
<url>
|
|
||||||
<loc>{{ site.url | append: site.baseurl | append: page.url | remove: "index.html" }}</loc>
|
|
||||||
<lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
|
|
||||||
|
|
||||||
{% if page.sitemap.changefreq %}
|
|
||||||
<changefreq>{{ page.sitemap.changefreq }}</changefreq>
|
|
||||||
{% else %}
|
|
||||||
<changefreq>monthly</changefreq>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if page.sitemap.priority %}
|
|
||||||
<priority>{{ page.sitemap.priority }}</priority>
|
|
||||||
{% else %}
|
|
||||||
<priority>0.3</priority>
|
|
||||||
{% endif %}
|
|
||||||
</url>
|
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
</urlset>
|
|
Loading…
Reference in a new issue