jekyll-last-modified-at

2019-05-23

use last modified date of the file to generate sitemap.xml

outline

in our blog, we use

<lastmod>{{ site.time | date: '%Y-%m-%d' }}</lastmod>

this code for sitemap.xml. this means last modified date of all pages is last build date of jekyll. so we were wondering google crawler is too busy to crawl actually modified page because of actually not modified page. therefore, we decided to use jekyll-last-modified-at plugin to generate the actually modified date to sitemap.xml

plugin

you can see all details about jekyll-last-modified-at to click below link. we will introduce how to install and use jekyll-last-modified-at.

install plugin

execute below command to install jekyll-last-modified-at plugin.

gem install jekyll-last-modified-at

how to use

insert one of below codes you want to show the date.


{% last_modified_at %}

{% last_modified_at %Y:%B:%A:%d:%S:%R %}

{{ page.last_modified_at }}

{{ page.last_modified_at | date: '%Y:%B:%A:%d:%S:%R' }}

we changed the code in ```sitemap.xml`` like below.

<!-- <lastmod>{{ site.time | date: '%Y-%m-%d' }}</lastmod> -->
<lastmod>{{ post.last_modified_at | date: '%Y-%m-%d' }}</lastmod>

check

we checked the code is changed to the modified file date.

bundle exec jekyll build

we don’t know actually this affects to google crawler, but we satisfy it because of done it like a programmer.

Buy me a coffeeBuy me a coffee
Posts