Make Your Blog More Evergreen with Movable Type
A recent post on ProBlogger discussed the pros and cons of dates on blog posts. The gist of it is recent dates can make posts appear fresh, but a post with an older date might appear stale, even if the information is still relevant.
One option discussed in the article was removing dates from older posts. This seemed like an interesting idea to me, so I set out to see how it could be done with Movable Type. It’s fairly easy, although it does require either a plugin or some PHP code.
Let’s start with the plugin version. We’ll need to install DateTags. This is an older plugin that’s not entirely compatible with MT4. In particular, there’s a problem with the
<MTNextNEntries> tag. We don’t need that tag for this, so for our purposes it will work fine.
After you install the plugin, open your Entry Metadata template module and add this code to the top:
Simple, right? Let’s go through it, though, and see what’s going on.
MT uses the Entry Metadata template module in a lot of different templates, but I only want to control the appearance of dates on individual entry archives. You can skip this check if you want the change to be site-wide.
This is the real meat of it. We use the
<mt:deltadays> tag from DateTags to find the difference between the entry date and the current date. We then store that value in the
Now we check
daysdiff to see the age of our entry. I’m checking if it’s about 6 months (180 days) old, but you can use whatever length you want. We then set another variable,
displaydate, based on that age.
A bit further down in our template, we use
displaydate to determine, well, whether we display the date:
on “><$MTEntryDate format="%x %X"$>
“><$MTEntryDate format="%x %X"$>
If you’re using the “About This Page” widget, you’ll want to do the same thing there. Remember, variables declared in one part of a template (or in an included template module) are available to any code that follows, so we don’t have to recalculate the date difference in the widget, just check
Using this method, you should get into the habit of regularly republishing your entire blog. That way, older posts will get updated as they “mature.”
If for some reason you can’t or don’t want to use the DateTags plugin you can still accomplish this by publishing your entry archives as PHP files. Just use this bit of PHP code to calculate your date difference:
‘)) / 86400, 0 );
Then use PHP instead of MT to test whether or not to display the date. The nice thing about this option is you don’t have to worry about republishing regularly to make this work — PHP will handle that automatically.
And there are other uses for this technique as well, like changing CSS files based on the age of the entry. You could set up a series of styles that cause your entries to “age” over time.
How do you highlight (or hide) the age of your posts? Let us know in the comments.