Shopify Liquid Code to Add Last Modified/Updated Date

Updated 06/27/2024, Posted 06/20/2024 by James Parsons James Parsons 0 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

Hi, I'm James Parsons! I founded Content Powered, a content marketing agency where I partner with businesses to help them grow through strategic content. With nearly twenty years of SEO and content marketing experience, I've had the joy of helping companies connect with their audiences in meaningful ways. I started my journey by building and growing several successful eCommerce companies solely through content marketing, and I love to share what I've learned along the way. You'll find my thoughts and insights in publications like Search Engine Watch, Search Engine Journal, Forbes, Entrepreneur, and Inc, among others. I've been fortunate to work with wonderful clients ranging from growing businesses to Fortune 500 companies like eBay and Expedia, and helping them shape their content strategies. My focus is on creating optimized content that resonates and converts. I'd love to connect – the best way to contact me is by scheduling a call or by email.