Adding a date to your Radio archive pages

Day 8 of Mark Pilgrim’s “30 days to a more accessible weblog”: Constructing meaningful page titles. Mark writes:

“Every page of your weblog should have a unique and meaningful page title… Date-based archive pages should include the name of your weblog, followed by the date (or date range) for the page…

“Unfortunately, I do not know how to customize page titles satisfactorily in Blogger or Radio. Radio has a <%longDate%> macro, but it can not be used as part of the page title…”

It’s true that longDate doesn’t work in the template, but there is a way to do this. Here’s how:

1. Edit your home page template.

  1. Find the line (probably near the top) which reads:

<title><%title%></title>

  1. Between <%title%> and </title>, add the following macro:

<%local (d); if radio.weblog.file.getArchiveFileDate (radioResponder.fileBeingRendered, @d) {": " + string.dateString (d)} else {""}%>

Note: be careful if you copy and paste this code — there should be no line-breaks.

  1. Click the Submit button.

The next time any of your archive pages are published, they’ll have a date in their title.

There’s no need to stick with the default date format. You can format the date however you want — Just replace the string.dateString (d) part with your own code. See the DocServer pages for the date and string verbs for some places to start digging.