XML Sitemap in the WordPress SEO plugin
There have been some questions after the release last weekend of the new XML sitemaps implementation in WordPress SEO. Let me try to address most of those questions in one post as well as explain the ideas behind it.
The basic idea behind the rebuild of the XML sitemap functionality was simple: XML sitemaps needed to be more scalable, have a better API and cause less issues. Most of the issues were caused by two causes:
- the fact that I was writing XML sitemaps to disk as static files;
- the fact that I tried to generate one huge sitemap to catch everything.
Both of these were not really design decisions, just how it “turned out” when I had built the functionality and they turned out to be stupid. So, with the help of the incredibly talented Jon Cave, a WordPress core dev from the UK, the XML sitemap functionality has been rebuilt. It now has an index sitemap file that points to several sitemaps, one for each post type and taxonomy.
If you have more than 1,000 posts in a post type, for instance more than 1,000 posts, it will automatically start splitting these sitemaps up into 1,000 posts sitemaps, so as to reduce the load time per sitemap. These sitemaps are generated in a completely new way, on the fly, without caching them to disk. This means there won’t be a delay anymore (caused by the generation process) when you publish a new post.
The sitemap index file can always be found at sitemap_index.xml, a link to that can be found from the new XML sitemaps menu.
The new code also means there’s a great new API for XML sitemaps, which will first be used in the Google News module. Documentation for that is coming. Because of a new filter in the code, NextGen Gallery will now also be able to add its images into the sitemap, so all of your images can be found by Google.