Skip to content Skip to sidebar Skip to footer

Google xml sitemap stylesheet loading error

Reading Time: 2 minutes

If you’re using google xml sitemap wordpress plugin(Google sitemap generator,google-xml-sitemaps-v3-for-qtranslate,..etc), you will notice an error message when you’re accessing your sitemap.This error message like this.
Google XML Sitemap Stylesheet loading Error

The main reason is this plugin can’t access directly sitemap.xsl or it not exist in the directory.The sitemap.xsl file is design your sitemap.xml file.It not essential to sitemap.xml file.
Another reason is your security plugins may not directly access this sitemap.xsl file for security reasons.
You can follow these any mothod to slove this problem.

You definitely need an XML Sitemap. In my personal experience with SEO, Google, and small business websites, XML Sitemaps have been an invaluable tool. Most people don’t know what Sitemaps are and often pay others to do SEO work – this is an advantage for you over your competition. One of my SEO “secrets” is to install the XML Google Sitemaps Plugin in my websites. I usually see results within a few days from using that Sitemap plugins!

Method-1

1- Go to the /wp-content/plugins/google-sitemap-generator folder.
2- Open the sitemap-core.php file.
3- Find the following function and full comment or remove it.

function GetDefaultStyle() {
        $p = $this->GetPluginPath();
        if(file_exists($p . "sitemap.xsl")) {
            $url = $this->GetPluginUrl();
            //If called over the admin area using HTTPS, the stylesheet would also be https url, even if the blog frontend is not.
            if(substr(get_bloginfo('url'),0,5) !="https" && substr($url,0,5)=="https") $url="http" . substr($url,5);
            return $url . 'sitemap.xsl';
        }
        return '';
}

 

4- Add this function after above.

function GetDefaultStyle() {
        $p = $this->GetPluginPath();
        if(file_exists($p . "sitemap.xsl")) {
            return '/wp-content/plugins/google-sitemap-generator/sitemap.xsl';
        }
        return '';
}

 

5- Rebuild your sitemap manually using plugin settings.

Method-2

This is the other reason.Your site using www or without.Use only one.You can do this by editing .htaccess file.
Add the following script and save the file.
If your site is using www, then add this script and save the .htaccess file.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

If your site is using without www, add this script and save the file.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Method-3

1- Go to the root directory and open your sitemap.xml file.
2- Find the following script there.(normally top).This script is loading styles/css to your xml file.

xml-stylesheet type="text/xsl" href="http://example.com/wp-content/plugins/google-sitemap-generator/sitemap.xsl"

3- Change it as follows.(remove the http://domain.com)

xml-stylesheet type="text/xsl" href="wp-content/plugins/google-sitemap-generator/sitemap.xsl"

4- Save the file.That’s only.
5- Or you can completely remove the above script.