XML Sitemap

Sitemap is always should be enabled. Slim SEO automatically generates XML sitemap (at domain.com/sitemap.xml) to submit to search engines. With XML sitemaps, your website is indexed fast and completely.

Slim SEO provides a styling for sitemap, which makes it look beautifully. See demo here.

To optimize the performance when generating sitemaps, the plugin splits the main sitemap (sitemap index) into a list of smaller sitemaps:

  • Post types: each post type has a sitemap.
  • Taxonomies: each taxonomy has a sitemap.

The maximum number of links in a sitemap is 2000. You can use filters to change this number (see below).

The posts and terms which are manually set as noindexed will be excluded in the sitemap.

Image Sitemap

Slim SEO also includes the image sitemap by default to make sure your images are discoverable by search engines.

All the images that you insert in the post content are added in the image sitemap. So, when someone search for your images, they’ll go to your posts to see the images.

The sitemap includes both self-hosted images and external images. Images in galleries or shortcodes are also parsed and included, too. For that reason, Slim SEO works with default WordPress gallery shortcode and other WordPress gallery plugins.

Please note that the image URLs are not visible to humans when you view the sitemap link. But they’re there if you view the sitemap source code as they’re made for search engines only.

Sitemap and robots.txt

The sitemap URL is automatically included in the robots.txt on your website if your website doesn’t have a physical robots.txt file. WordPress automatically creates a virtual robots.txt for your website at domain.com/robots.txt. If you have a physical robots.txt, you need to add the sitemap URL by yourself.

How to remove a post type from the sitemap

To remove a post type from the sitemap, use the following code:

add_filter( 'slim_seo_sitemap_post_types', function( $post_types ) {
    $post_types = array_diff( $post_types, ['your_post_type'] );
    return $post_types;
} );

How to remove a taxonomy from the sitemap

Similar to above, please use the following code:

add_filter( 'slim_seo_sitemap_taxonomies', function( $taxonomies ) {
    $taxonomies = array_diff( $taxonomies, ['your_taxonomy'] );
    return $taxonomies;
} );

If you want to remove all taxonomies from the sitemap, use the following code:

add_filter( 'slim_seo_sitemap_taxonomies', '__return_empty_array' );

How to change the query for posts in the sitemap

Please use the following snippet:

add_filter( 'slim_seo_sitemap_post_type_query_args', function( $query_args ) {
    // Change number of URLs
    $query_args['posts_per_page'] = 5000;
} );

How to change the query for taxonomies in the sitemap

Similar to above, please use this snippet:

add_filter( 'slim_seo_taxonomy_query_args', function( $query_args ) {
    // Change number of URLs
    $query_args['number'] = 5000;
} );

Core sitemaps in WordPress 5.5

Since version 5.5, WordPress includes sitemap functionality in the Core. Currently, the core sitemaps lack some features that Slim SEO provides such as image sitemaps. So we temporarily disable the core sitemaps feature in WordPress to avoid any conflict. We’ll work on a deep integration with core sitemaps to make sure Slim SEO works well with it.