Fix XML declaration allowed only at the start of the document Sitemap Error

Have you ever seen the Sitemap error “XML declaration allowed only at the start of the document?” The day before yesterday I was trying to check my sitemap which is created by Yoast SEO plugin. I found that the sitemap is missing and a sitemap error is coming quoted XML declaration allowed only at the start of the document.

Now the question comes is why this error is coming and how can we solve that? You very well know the importance of sitemap for a site. A sitemap is like a table of contents for Search Engine like Google.

A website sitemap tells a search engine about the latest changes and modifications performed on a website web pages. You can read about the process of creating a sitemap and importance of sitemap here.

How to create a Sitemap for a WordPress Website with pictures?

How to create an XML sitemap for a non-WordPress website?

From SEO perspective also a sitemap is very important. So, always keep your sitemap updated and free from any errors. To get better results and ranking in SERPs you have to submit your sitemap to Google Search console. If you do so, Google will discover, crawl and index your site.

Read AlsoGoogle Fast indexing

Now let’s focus on solving the sitemap error “XML declaration allowed only at the start of the document.”

Why this “XML declaration allowed only at the start of the document” occurs?

There can be a lot of reasons but the main reason is unstructured data in the main code of the WordPress theme. Do you know why I have got the error? As I was editing the functions.php file and while edition I have misplaced some of the tags.

Generally, it is unwanted use of spaces in between the tags. The sitemap error “XML declaration allowed only at the start of the document” will look like this.

XML declaration allowed only at the start of the document
XML declaration allowed only at the start of the document error

So, now the question appears how this sitemap error can be fixed? Let’s have a look at this.

Fixing “XML declaration allowed only at the start of the document”

There are few things which you have to kept in mind. it will help you to fix this Sitemap problem easily.

  1. Make sure your PHP file doesn’t have any space prior the PHP tag
  2. If your website is new then you should reinstall your theme
  3. If your website is old then try replacing your core files code on by one. You can also check the code different from the main theme.
  4. You should reverse any changes made in the theme code, just to verify if the problem is resolved.
  5. Try deactivating plugins one by one to check if the problem still exists.
  6. Make sure you don’t have multiple plugins for sitemap creation
  7. Don’t add any extra declaration which is not required

I hope if you follow this then the problem “XML declaration allowed only at the start of the document” will be fixed. As I have experienced this error mostly comes due to extra spaces before the PHP tag. So keep this in mind.

If you are not able to solve this problem then comment below or contact us. We will try to help you personally.

Thanks for reading this article.

Have a good day!

Read NextGooglebot optimization for better SEO | A level up SEO tactics

How to Create XML Sitemap For Non WordPress Websites?

XML Sitemap generation – Do You know how to Create XML Sitemap for Non-WordPress Websites? Like creating XML Sitemap for Blogger Blogs, Static PHP websites (like a Music Websites). XML Sitemap generation is an important part of blogging. You have to generate and Submit your Website XML Sitemap to Google, Bing, and Yandex.

So, let’s start the topic which what is Sitemap?

What is Sitemap?

By placing a formatted XML file with Sitemap on your website, you allow Search Engine crawlers (like Google) to find out what pages are present and which have recently changed, and to crawl your site accordingly.

So, In general, a Sitemap is a map of your full site which represents each and every aspect of your blog/website.

In WordPress, Sitemap generation is bit easy. You have plugins Like Yoast SEO and All In One SEO which works great in this regard.

I will talk later in this article how to generate a sitemap using Yoast SEO.

But for a Non-WordPress Website. It is not easy. There are a lot of tools which can generate a sitemap. But the main problem occurs in Webmaster Submission.

You have to create your sitemap on regular basis and then you have to submit that sitemap to webmaster manually. This process is little hectic.

So, You need a Sitemap generator, which not only generates your sitemap but also confirms webmaster submission at regular intervals.

Yes, you heard right!

Today, I am going to tell you about a website which works perfectly in this regard. The Site is

Watch our Video tutorial about XML Sitemap generation

XML Sitemap generation & Auto Submission using – an Overview not only create a sitemap for your website but it also automatically submit the links to webmaster once you publish a new link.

By Using This Website You can create and Submit XML-Sitemap for any type of website. Let’s See some of the features provides by

Features of Website –

1. You only need to provide your website URL

2. They will create an XML sitemap for you from their server and optionally will keep it up-to-date

3. They host your sitemap files on their server and ping search engines automatically

4. No software installation is required on your computer or your server

5. They can create and maintain Images, Video, News sitemaps and RSS feed, track broken links, internal and external links, analyze site structure and site history as well

Create your Sitemap Now

How to Submit Your Sitemap to Google, Bing, and Yandex?

For a WordPress Website, It’s easy. you can generally find your sitemap at http://domainname/sitemap.xml or http://domainname/sitemap_index.xml.

To Submit it to Search Engines, you can go through this post – Sitemap Submission

For, a Non-Wordpress website you can take help of They are providing Sitemap hosting feature. You just have to go through this process once.

Once done, forget sitemap submission process.

xml sitemap generation and auto submission

You can check and repair broken links also.

You can easily see external links on your site.

Mobile apps are provided to easily manage and submit your sitemap.

XML Sitemap generation using Yoast

First You need to Install the Plugin Yoast SEO. I don’t need to tell you how to install a plugin. After Installing, Go to Yoast-> General->Features and Switch on the XML Sitemap generator button.

XML sitemap generation using Yoast

After Switching it on, You can find Your sitemap at http://domainname/sitemap.xml or http://domainname/sitemap_index.xml.

So, I hope this article will be helpful to you in XML Sitemap generation process. Good Luck!!

Read NextHow to Rank a keyword?

What Can A sitemap do?

An XML Sitemap will boost your organic traffic.

Search Engines can easily index your site time to time whenever a changes occur on your site.

You can monitor which post is performing well.

You can see no of click you get per day.

Using this you can optimize your website and contents according to Google guidelines.

This is just a basic introduction, you can do even a lot.

When can you Submit Your Sitemap?

This is an important step, You don’t need to submit your sitemap after publishing your post.  If you want to submit at that time then You can only submit your Post Sitemap.

A plugin like Yoast SEO divides your sitemap into different categories like you can see below –

Sitemap Last Modified
Blog Post Sitemap 2018-04-05 21:46 +05:30
Webpages Sitemap 2018-04-04 18:42 +05:30
Product Page and products Sitemap 2018-04-04 13:21 +05:30
Template Sitemap 2018-03-18 20:26 +05:30
Gallery Sitemap 2017-11-06 09:25 +05:30
Album Sitemap 2017-11-06 09:26 +05:30
Categories Sitemap 2018-04-05 21:46 +05:30
Post Tag Sitemap 2018-04-05 21:46 +05:30
Post Tag 2 (When limit is exceeded) 2018-04-04 12:49 +05:30
Product Category Sitemap 2018-04-04 13:21 +05:30
Author Sitemap 2018-03-23 15:20 +05:30

So, the best time to submit your sitemap is when your website is completely developed.