Format Your Blog Post Dates to Include the Year (Automatically)

Squarespace blog templates sometimes only show the month and day of publication — for example:

April 26

That might be fine for casual blogs, but if you’re writing content that people cite, reference, or revisit over time, not including the year can create confusion. This is especially important for academic-style writing, evidence-based content, or anything evergreen.

What This Code Fixes

This small snippet of JavaScript scans your blog posts for hidden or incomplete date elements. It checks if there’s a <time class="dt-published"> element on the page, grabs the full date (from either the tag or its fallback metadata), and reformats it into a standard, complete date like:

April 26, 2024

It runs automatically once the page loads, and works on most Squarespace templates.

How to Use It

  1. Go to your blog post in Squarespace

  2. Click the ⚙️ SettingsWebsite ToolsCode InjectionFooter Code

  3. Paste the following code into the Footer field:


<!-- 📅 Format Published Dates -->
<script>
document.addEventListener("DOMContentLoaded", function () {
  document.querySelectorAll("time.dt-published").forEach(el => {
    const dateText = el.getAttribute("datetime") || el.textContent.trim();
    const metaDate = document.querySelector('meta[itemprop="datePublished"]');
    const year = metaDate ? new Date(metaDate.content).getFullYear() : new Date().getFullYear();
    const fullDate = new Date(`${dateText} ${year}`);
    if (!isNaN(fullDate)) {
      el.textContent = fullDate.toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" });
    }
  });
});
</script>

That’s it. Once saved, the year will be automatically appended to blog post dates — no need to manually edit anything.

Troubleshooting

  • This only works if your template uses <time class="dt-published"> — which most Squarespace blogs do by default

  • If your date still looks incomplete, inspect the element (right-click → Inspect) to make sure the class name matches

  • Dates pulled from datetime attributes or meta tags are usually accurate, but always double check older posts if the content was imported

Optional Tweaks

Want a different format? You can adjust the toLocaleDateString() line:

{ year: "numeric", day: "numeric", month: "short" }

... would give you something like:

26 Apr, 2024

Simply Put

This is a quiet but important upgrade — especially if your content is meant to last. Adding the year gives your posts more credibility and clarity, especially when readers return months (or years) later.

Is This Free to Use?

Personal use is free forever.
If you’re using this tool on your own blog, portfolio, or personal Squarespace site, you don’t need to pay — enjoy it freely.

Commercial use requires a one-time license.
If you’re a developer, agency, or using this on a client project or monetized site, please purchase a commercial license. It helps support ongoing development and gives you peace of mind.

One-time cost: £49.99 (normally £79.99)
Covers unlimited client sites, all current tools, and future updates.

👉 Learn more or buy a license here

Frequently Asked Questions

How do I show the year in a Squarespace blog post date?
This tool adds the year automatically to your blog post dates using a lightweight JavaScript snippet. It works by detecting Squarespace’s default <time class="dt-published"> elements and appending the correct year.

Why doesn’t Squarespace show the year in blog post dates by default?
Some templates only display the month and day to keep designs minimalist. However, this can cause confusion — especially on evergreen content or academic blogs.

Can I change the date format in Squarespace without a plugin?
Yes. This script lets you fully customize your date format using JavaScript — no plugins or developer tools needed.

Will this work on all Squarespace 7.1 templates?
Most Squarespace templates use the dt-published time element, which this script targets. You can double-check by inspecting your blog post's date element.

Does this update past blog posts as well?
Yes. Once the code is added, it runs on every page load and updates all visible blog post dates, past and future.

Is a license required for commercial use?
Personal use is free. If you’re using this tool on a commercial or client site, you’ll need a commercial license (£49.99 one-time).

Disclaimer

This script is provided as-is with no guarantees. While it's designed to be safe for most Squarespace sites, always test changes before going live — especially if you’ve installed third-party plugins, custom fonts, or heavy integrations. By using this code, you accept that we are not liable for any unexpected behavior or performance changes.


JC Pass

JC Pass is a specialist in social and political psychology who merges academic insight with cultural critique. With an MSc in Applied Social and Political Psychology and a BSc in Psychology, JC explores how power, identity, and influence shape everything from global politics to gaming culture. Their work spans political commentary, video game psychology, LGBTQIA+ allyship, and media analysis, all with a focus on how narratives, systems, and social forces affect real lives.

JC’s writing moves fluidly between the academic and the accessible, offering sharp, psychologically grounded takes on world leaders, fictional characters, player behaviour, and the mechanics of resilience in turbulent times. They also create resources for psychology students, making complex theory feel usable, relevant, and real.

https://SimplyPutPsych.co.uk/
Previous
Previous

Customize Author Links on Your Squarespace Blog Posts

Next
Next

Add a Sliding Summary Drawer to Your Squarespace Blog Post