How to implement SEO with MaxCDN

I have heard of the term CDN or content delivery network for long time now and have seen many websites using it, however, I thought that it was complicated to setup after reading several articles online. So I didn’t use any CDN solution up until the beginning of last month. Sounds super crazy isn’t it? I mean you don’t necessary need CDN to speed up your WordPress or website. As long as it site is running on some of the best hosting company then you’re good. But it wouldn’t hurt to do some optimizations right?

So I finally setup an account at MaxCDN and got it to work with WordPress in just a few minutes. Several days went by and I notice something changed, Google has stopped indexing images on my blog. Did some searching on Google and landed on one of Brian Jackson’s site called OkayMarketing. I got in touch with him on Twitter and find out that we were facing the same issue. Brian was kind enough to walk me through this and I got Google to start indexing my images again.

From this I also learned that people might not get this error but another one where MaxCDN will cause duplicate content because your files are now being hosted on two different URLs. In this article, I will show you how to resolve these problems in the same way.

Let’s go ahead and login into your MaxCDN control panel. Go to the SEO settings of your pull zone and enable both Canonical Header & Robots.txt. Inside the robot.txt box you should have something like this. If not, just copy what I have below and paste it into there.

User-agent: *
Allow: /wp-content/uploads/
Disallow: /

maxcdn-seo-settings

The last step would be changing the images path in your Sitemap file. Majority of us now uses Yoast SEO plugin so add this code below in your current theme’s functions.php file.

functionwpseo_cdn_filter( $uri) {
returnstr_replace( ‘http://yourdomain.com’, ‘http://cdn.yourdomain.com’, $uri);
}
add_filter( ‘wpseo_xml_sitemap_img_src’, ‘wpseo_cdn_filter’);
Don’t forget to change yourdomain.com to your WordPress address and CDN url. Do a quick cache in W3 Total Cache or any plugin that you have. Wait for a day or two and everything should go back to its normal mode. Let me know if you have questions.
0Shares

Related posts:

2 thoughts on “How to implement SEO with MaxCDN”

Leave a Reply

Your email address will not be published. Required fields are marked *