[wp-hackers] Should Monthly Archive Pages ever return 404?
mike at zed1.com
Mon Mar 9 21:13:50 GMT 2009
In the context of the WordPress 'framework', of a blog returning date
based-posts from a URI that has a specific meaning, then a URI that
was not generated by the system, by WordPress itself, can only
logically return a 404. "The resource was not found".
If you choose, through your theme and or plugins, to include other
data in this or any other response, then that it perfectly valid but
it is not a direct default function of WordPress.
Now, WordPress does have hooks in place to filter a 404. Take a look
at the actions 'redirect_canonical' and 'template_redirect'
By the way, Mike, you mention a calendar link which points to a month
with no posts. That must be either a non-WP calendar, one modified by
a plugin, or you have found a bug in the calendar code. The standard
calendar does not generate links for months in which there are no
To look at the issue from another perspective: That of an indexing
search engine. If it follows a URI with the intention of indexing the
resource on the other end of the URI, if it always gets back a 200 for
every possible URI, then the indexes will pretty soon fill up with
crap. You now have the situation when every possible date-based URI
from the year zero onwards is valid, presumably including the ones in
the future, forever!
Imagine if your 'standard' extra non-post content was a page full
adverts. Oh wait, we have that already, they are called spam sites,
and we all hate them.
So the correct response is 404, and the search engines can safely
choose to not index that page. Note that they can and will come back
to the same URI in case it becomes valid (when a 200 should be
Mike, I believe what you really need to do is hook one or both of the
actions above and return a 302 redirect to your 'invalid date handler'
page. Which might do something useful like suggest another link,
display a year calendar, or simply say, "Hey, no posts for this date,
but here are my tweets, and my flickr posts, some interesting
historical facts for this month, etc."
It should be 302 in case there ever are posts for that date, whereupon
those posts should be returned with 200 response code.
More information about the wp-hackers