Home » How to do » How to fix XML sitemap error SEO by Yoast | error on line 2 at column 6

How to fix XML sitemap error SEO by Yoast | error on line 2 at column 6

xml sitemap error

Error codes:

SEO error xml sitemap


  Error 404 page not found


I was involved in an XML sitemap error by WordPress using the SEO plugin by Yoast. I was trying to find the solution over the different forums and posts but I couldn’t fix the problem, I felt like banging my head on the wall for not finding the solution to the problem. Finally, I discovered the solution to this particular problem and thought to share my experience with all of you who are actually experiencing this annoying situation.

Identified problems and solutions

Many people have looked into it in their own perspective and proposed different solutions. Some people said it is the problem with the SEO by Yoast plugin and you have to edit the plugin’s file and provided some additional rewriting codes to put in plugin’s .htaccess file in order to get it fixed and generate the sitemap for you. Some people suggested turning on and off the plugin will fix the problem. Some said your theme is poorly coded because of that you are getting that kind of error. Moreover, there were many different opinions and proposed solutions that may have worked well for some people but none for me.

The real problem

In many forums I have come across the argument that the real issue is with one or more of the plugins that you have installed in your WordPress, some of the plugins may create white blank space after opening  <?php or the closing tag ?>. So that was the real problem in my case

How did I find the problem?

Once I took this suggestion that the problem is being caused by one of the plugins that I have installed on my WordPress I thought to analyze it thoroughly step by step to find out where the problem lies.

Step 1

I turned off-deactivated each and every plugin that was installed on my WordPress except SEO by Yoast and then generated the sitemap and boom. The sitemap was generated without any problem. This way I figured out that there is nothing wrong with SEO by Yoast neither with my WordPress theme coding rather there is definitely something wrong with one of the plugins that I have installed.

Step 2

Now that I have figured out the real problem is with one of the plugins, in the next step I started reactivating the plugins one by one to figure out which one is causing the problem. I activated the first plugin and regenerated sitemap it was ok. Then I activated the second plugin and regenerated sitemap, all perfect. Then I turned on third Email subscriber plugin and regenerated sitemap, got stuck again that error 404 or line 2 column 6 error was found. Then I deactivated back my email subscriber plugin and checked other plugins that were left to see if any more plugins have the same problem or not. But none of the others were causing the issue. This way I came to the conclusion that there is only one plugin that has to be fixed.

Step 3

Now all of the other plugins were activated except my email subscriber and there was no issue in generating sitemaps using SEO by Yoast. I went to the email subscriber plugin’s editor to check what’s wrong with the coding keeping that white space and empty line after opening <?php or the closing tag ?>  in my mind, I checked the plugin’s code and found the empty space after the closing tag ?>  you can see it in the picture below

error 2

Then I removed this space by using backspace and it looked like this after removing the space (see picture below)

error 3

I also checked the files opening tag  <?php to see if there is empty space before or after the tag but it was ok and looked like this (see picture below)

error 5

You also have to remove the space if it exists before or after the opening tag <?php which will look like this (see picture)

error 6

Just look for opening or closing tags and remove the space by using your computers backspace and update the file. Once you updated the file after removing space you are ready to generate an XML sitemap without any issue.

Bottom line

I believe in most cases the problem would be more or less the same, just follow the steps mentioned above and you will fix your problem. You don’t need to edit your theme’s coding, SEO plugin’s coding or any other suggested a fix in this case.

tracking website performance is important ignoring sitemap submissions can cause problems

Image credit: managewp.com
Mark Goodman

Digital marketing enthusiast and industry professional in Digital technologies, Technology News, Mobile phones, software, gadgets with vast experience in the tech industry, I have a keen interest in technology, News breaking.

11 thoughts on “How to fix XML sitemap error SEO by Yoast | error on line 2 at column 6

  1. I had this problem and simply turn off all plugins, apart from yoast SEO, then go to yoast’s sitemap area and view your site map, you may still get a 404 but come out, turn the plugins back on then you should see the sitemap has appeared. Not sure how but I presume one or some plugins are blocking yoast from creating it.

    Good luck

  2. Hello Dear,
    We’ve written an article about common sitemap errors which you can find here.
    Solution is very easy and it will work 100%.

Comments are closed.