Today on Crunchify, we have made few changes and would like to share changes to my readers. SEO is really tricky. Sometimes you need to know what are the best SEO settings and changes.
In this tutorial we will go over changes related to attachment pages, how to remove it from Sitemap.xml file and how you could redirect attachment pages to parent pages.
What is sitemap in WordPress world?
Sitemap.xml is a file consist of your list of all posts, pages, images and attachments. Do I have to have sitemap.xml? Google says – you don’t need sitemap file if your site is small. No matter what Google is going to crawl your site anyways.
Then why we need sitemap.xml?
sitemap.xml file if your site is very big, you have separate site structure, dedicated news blog and complex site.
On Crunchify, we are using
Yoast SEO Premium plugin. It by default adds attachment pages to your sitemap.
Take a look at
Post Types page under
Make sure you set
Not in Sitemap option for your site. There is no point adding attachments to your sitemap. Google mainly index your dedicated page if it has some lengthy contents and some value added description.
Mainly for attachment pages there is no post contents and Google usually see no value indexing those pages.
For SEO (Search Engine Optimization) best practice it’s also advisable to redirect all individual image page to parent post.
Take a look at this:
Here first URL is a attachment page which is redirecting to it’s parent page.
Then how to redirect Attachment pages to Parent page?
There are couple of ways you could redirect attachment pages to parent page.
If you are using Yoast SEO plugin then just go to
- Permalinks tab
Make sure you select
Redirect option as you see in below diagram.
And you are all set. Now all your attachment pages will be redirected to Parent page.
crunchify-image.php file and put below code into it.
<?php wp_redirect( get_permalink( $post->post_parent ), 301 ); exit; ?>
There is a WordPress plugin out there called Attachment Pages Redirect which does exactly the same if you want to avoid any custom settings and you don’t use Yoast SEO plugin.
What to do after making above changes?
- Regenerate your sitemap.xml file
- Resubmit it to your Google Search console
Join the Discussion
Share & leave us some comments on what you think about this topic or if you like to add something.