Earlier WordPress had a clear territory for plugins and themes. For example, social sharing is considered as part of plugin development. However, this boundary becomes thin and thin with Gutenberg block editor grabbing many plugin features. In addition, WordPress core also grabbing features like lazy loading and XML Sitemap. In this article, let us explain where you can find the default WordPress XML Sitemap and what happens if you are already using a plugin for generating XML Sitemap for your site.
WordPress XML Sitemap
WordPress introduced XML Sitemap as part of version 5.5. Therefore, if you have WordPress version 5.5 or greater on your installation, you will have an automatic XML Sitemap generated for your site.
- WordPress generates a sitemap index file and can contain up to 50,000 individual sitemaps.
- Each individual sitemap can contain up to 2,000 URL.
- WordPress will insert a sitemap directive in robots.txt file so that search engines can easily find the location of your sitemap.
Where Can I Find WordPress XML Sitemap?
The standard way of using sitemap is to place the XML Sitemap file in root of the WordPress installation. It means, users and search engines should be able to access the sitemap by adding “/sitemap.xml” suffix to your WordPress site URL. Many SEO and general plugins already offer this way of generating XML Sitemap. In order to avoid conflicting with this method, WordPress creates sitemap with different URL.
You can find the default WordPress URL by adding “/wp-sitemap.xml” to your site URL. For example, https://www.webnots.com/wp-sitemap.xml is the default WordPress sitemap for this website. Below is how it will look on the browser.
What Happens If I Already Use a Plugin?
As mentioned, many plugins generate XML Sitemap which you can submit to Google and other search engines. Plugins like Yoast SEO will generate sitemap index file that you can access by adding “/sitemap_index.xml” to your site URL. The standard “/sitemap.xml” URL will redirect to “/sitemap_index.xml” URL. This index sitemap contains the detailed sitemaps for posts, pages and other custom post types on your site.
In this case, you will end up having two sitemaps – one from the plugin and other from default WordPress. You can continue to use the plugin’s sitemap and submit that to search engine. However, make sure to setup redirect from WordPress sitemap to the correct sitemap URL that your plugin generates. In Yoast SEO, this redirection happens automatically and you do not need to do anything.
Can I Disable Default WordPress Sitemap?
Unfortunately, there are no option for enabling or disabling the default WordPress sitemap from admin panel. Generally, WordPress guys throw the functionalities like lazy loading, XML Sitemap, etc., to users without the possibility of controlling. However, you can add the following code in your functions.php file to disable the sitemap function completely.
add_filter( 'wp_sitemaps_enabled', '__return_false' );
Remember, WordPress also will disable the sitemap function when you discourage search engines from indexing your site under “Reading” settings.
Which is Best Option?
At this moment, we recommend ignoring the default WordPress XML Sitemap and use third-party plugins for the following reasons.
- There are no options to include or exclude specific post/page in the sitemap from admin panel.
- Similarly, you can’t exclude specific post type or taxonomy. By default, all content on your site will be part of the sitemap. We ignore tags by noindexing taxonomy in Yoast SEO which you can’t do with default WordPress sitemap.
- Default sitemap does not support custom post types unless you register the custom post type using sitemap provider PHP class.
- Having 2000 URLs per sitemap can easily break many of the server. It will also take long crawling time for search engine bots to crawl all URLs in the sitemap without delay.
- If you have single author blog, user sitemap will be repetitive of the post sitemap.
- It does not contain last modified date, number of images and other parameters.
So, with all these drawbacks, you can continue to use your plugin’s sitemap.
I Want to Use Default WordPress Sitemap
Well, if you decided to choose the default way then there are some customizations to add or ignore content. You can refer the complete guide on WordPress make portal and here we will touch up on some important aspects. You can add the following functions in your theme’s functions.php file to modify the behavior of the default sitemap.
Disabling Page / Post Sitemap
If you want to disable support for pages, use the below function.
add_filter(
'wp_sitemaps_post_types',
function( $post_types ) {
unset( $post_types['page'] );
return $post_types;
}
);
Replace the ‘page’ with ‘post’ to disable support for post in your sitemap.
Disabling Taxonomy
Use the below code to disable post tags support on your sitemap.
add_filter(
'wp_sitemaps_taxonomies',
function( $taxonomies ) {
unset( $taxonomies['post_tag'] );
return $taxonomies;
}
);
Replace, ‘post_tag’ to any other taxonomy to disable that from the sitemap.
Exclude Individual Post
Use the below code to exclude single post, by replacing 123 with your post id.
add_filter(
'wp_sitemaps_posts_query_args',
function( $args, $post_type ) {
if ( 'post' !== $post_type ) {
return $args;
}
$args['post__not_in'] = isset( $args['post__not_in'] ) ? $args['post__not_in'] : array();
$args['post__not_in'][] = 123; // 123 is the ID of the post to exclude.
return $args;
},
10,
2
);
Conclusion
WordPress by default does not offer any SEO features like adding meta description, minify files, etc. Adding WordPress XML Sitemap is a good step towards bringing SEO features to the core. However, the function is preliminary and do not have sufficient stuff to compete with the XML Sitemap offered by SEO plugins. We believe this will change in future by optimizing sitemap with all required options. Until then you can continue using your XML Sitemap plugin for submitting to search engines.
3 Comments
Leave your reply.