Site icon WPBrigade

How to implement SEO with MaxCDN

SEO with maxcdn, maxcdn

I have heard of the term CDN or content delivery network for a long time now and have seen many websites using it, however, I thought that it was complicated to set up 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 necessarily need CDN to speed up your WordPress or website. As long as its 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 set up 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: /

The last step would be changing the image path in your Sitemap file. The majority of us now use 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.
Exit mobile version