Quantcast
Channel: Crunchify
Viewing all articles
Browse latest Browse all 1037

Learn everything about WordPress Sitemap.xml, Attachments and Redirect Attachments to Parent Page

$
0
0

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?

We need 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 XML Sitemap:

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:

https://crunchify.com/fix-allowed-memory-size-exhausted-wordpress/Fix-PHP-Fatal-Error-Allowed-Memory-size-Exhausted/

https://crunchify.com/fix-allowed-memory-size-exhausted-wordpress/

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.

Method-1

If you are using Yoast SEO plugin then just go to

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.

Method-2

Create file crunchify-image.php file and put below code into it.

<?php wp_redirect( get_permalink( $post->post_parent ), 301 ); exit; ?>

Method-3

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.

Attachment Page Redirect

What to do after making above changes?

The post Learn everything about WordPress Sitemap.xml, Attachments and Redirect Attachments to Parent Page appeared first on Crunchify.

Author: App Shah

Crunchify, LLC Logo


Viewing all articles
Browse latest Browse all 1037

Trending Articles