Jekyllの記事に更新日を記す
これまでに公開した記事を改訂したくなったので、記事に更新日を明記します。
last_modified_at変数を表示する
jekyll-sitemapやjekyll-feedはpage.last_modified_atに既に対応しているとのことです。確かに、jekyll-feed-0.17.0のfeed.xmlに下記のような行が含まれていて、publishedタグにdate変数が、updatedタグにlast_modified_at変数が適用されることがわかります。
<title type="html">{{ post_title }}</title>
<link href="{{ post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post_title }}" />
<published>{{ post.date | date_to_xmlschema }}</published>
<updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
minima-2.5.2の_layouts/posts.htmlを./_layouts/以下にコピーしてきて下記のように編集します。
diff --git a/_layouts/post.html b/_layouts/post.html
index abf9696..8abc4a9 100644
--- a/_layouts/post.html
+++ b/_layouts/post.html
@@ -6,10 +6,17 @@ layout: default
<header class="post-header">
<h1 class="post-title p-name" itemprop="name headline">{{ page.title | escape }}</h1>
<p class="post-meta">
+ 公開:
<time class="dt-published" datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">
{%- assign date_format = site.minima.date_format | default: "%b %-d, %Y" -%}
{{ page.date | date: date_format }}
</time>
+ {%- if page.last_modified_at -%}
+ • 更新:
+ <time class="dt-published" datetime="{{ page.last_modified_at | date_to_xmlschema }}" itemprop="dateModified">
+ {{ page.last_modified_at | date: date_format }}
+ </time>
+ {%- endif -%}
{%- if page.author -%}
• <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span class="p-author h-card" itemprop="name">{{ page.author }}</span></span>
{%- endif -%}</p>
(追記) Schema.orgを眺めていてdatePublishedプロパティに加えてdateModifiedプロパティがあるのを見つけました。初出時には<span>に含めていた更新時刻を<time itemprop="dateModified">に含めるよう変更しました。
記事に更新日時を設定する
フロントマターのlast_modified_at変数を設定する。この記事では下記のように設定してみました。
layout: post
title: "Jekyllの記事に更新日を記す"
date: 2026-01-30 10:30:00 -1000
last_modified_at: 2026-01-30 14:20:00 -1000
categories: jekyll update
© 2026 by zunda <https://zunda.ninja>,
licensed under CC BY 4.0.