Shopify Liquid Code to Add Last Modified/Updated Date

James Parsons by James Parsons Updated Jun 27th, 2024 2 Comments

Most Shopify sites show the "Published" date on blog posts, and it's not always clear how to add the "Updated" or "Modified" date to your content instead.

Here's a code snippet I like to use for this:

Last updated <time pubdate datetime="{{ article.updated_at| date: '%Y-%m-%dT%H:%M:%SZ' }}">{{ article.updated_at| date: format: 'date' }}</time>

Simply modify your main-article.liquid file (or similar), look for the section in the code with the post date, and plop this code in there.

Some people choose to show the updated date instead of the publish date, like myself. Others like to show both and let Google pick which one they want to use. I've discussed and pros and cons of both in a blog post here, which includes a handful of quotes from other SEO experts I spoke with on this subject.

You can change the output of how the date looks by tweaking this part:

%Y-%m-%dT%H:%M:%SZ

Here are a few other variations, if you want the date to be displayed in a different format:

%Y-%m-%d
Output: 2024-06-20

%m/%d/%Y
Output: 06/20/2024

%d-%m-%Y
Output: 20-06-2024

%B %d, %Y
Output: June 20, 2024

%d %B %Y
Output: 20 June 2024

%B %-d, %Y
Output: June 20th, 2024

%d/%m/%Y
Output: 20/06/2024

%b %d, %Y
Output: Jun 20, 2024

%Y %B %d
Output: 2024 June 20

Please leave me a comment if this helped you or if you have any questions for me!

Related Code Snippets

Written by James Parsons

James Parsons is the founder and CEO of Content Powered, a premier content marketing agency that leverages nearly two decades of his experience in content marketing to drive business growth. Renowned for founding and scaling multi-million dollar eCommerce businesses through strategic content marketing, James has become a trusted voice in the industry, sharing his insights in Search Engine Watch, Search Engine Journal, Forbes, Entrepreneur, Inc, and other leading publications. His background encompasses key roles across various agencies, contributing to the content strategies of major brands like eBay and Expedia. James's expertise spans SEO, conversion rate optimization, and effective content strategies, making him a pivotal figure in the industry.