2023-10-16 hit count image

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


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


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>


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.

Was my blog helpful? Please leave a comment at the bottom. it will be a great help to me!

App promotion

You can use the applications that are created by this blog writer Deku.
Deku created the applications with Flutter.

If you have interested, please try to download them for free.