All About XML SitemapsJune 26th, 2014 by Eva Martin
All About XML Sitemaps
We often hear questions such as: What is an XML sitemap? What are the benefits of having an XML sitemap? Are there different types of sitemaps? How do I create one?
In today’s post, we’ll tell you everything you need to know about XML sitemaps, so let’s get right to it!
Why Do I Need a Sitemap?
Sitemaps are really useful to ensure your website is indexed correctly, as they help search engines during their crawling process.
The sitemap basically works like a road map, but for crawlers. Crawlers usually discover new pages via links (which is why it is important that your site is interlinked properly). However, a sitemap is used to double-check their indexed database, allowing them to discover pages they might not otherwise have found.
This is especially useful for new websites or websites with a large number of new or updated pages. Thanks to a sitemap search engines can find their pages much faster, reducing the amount of time it takes to index them.
Types of Sitemaps
There are two major types of sitemaps: HTML sitemaps and XML sitemaps.
HTML sitemaps are the classic sitemaps which your visitors may use to navigate your site. They can usually be found on a separate page. HTML Sitemaps are easy to create because they are basically web pages where you show the structure of the website by means of links.
Besides the obvious benefit for the users, HTML sitemaps can be useful for SEO too. If crawlers can easily find a link to an HTML sitemap, it can help them understand your site structure. Don’t forget to update your sitemap if you add or remove pages (you will probably have to do this manually).
XML Sitemaps are only used by search engines, which use this type of sitemap for their crawling process. XML sitemaps are very useful if you want to make sure that crawlers don’t miss any important pages or files within your website.
You can easily check whether your site has an existing sitemap by going to your site’s domain and adding /sitemap.xml, so for example http://www.example.com/sitemap.xml
You can automatically generate XML sitemaps with one of the dozens of online tools available, for example here or here. However, if you’re using a CMS such as WordPress, Joomla, Magento or Drupal, there are plenty of plugins available which can not only generate but also automatically update your XML sitemap.
Keeping your XML sitemap up to date is especially important for sites that regularly add or remove pages, such as online shops and magazines.
When creating an XML sitemap, there are some things you should keep in mind:
• All URLs in a sitemap must come from the same host.
• The maximum length for a URL is 2,048 characters (which should be more than enough).
• A sitemap can contain a maximum of 50,000 URLs.
• The maximum file size for sitemaps is 50 MB.
Once your sitemap has been created, it needs to be placed in the root directory.
Adding Information to Your XML Sitemap
A great thing about XML sitemaps is that they allow you to add additional information about the pages by using metadata. Let’s look at an example:
The first part (until </urlset>) tells search engines how the sitemap is encoded.
The second part (between <url> and </url>) shows a URL entry, i.e. a specific page on your site. It is here that you can add further information.
The loc tag indicates the location of the page. This is the only tag which is required, all others following below are optional.
The lastmod tag shows the date when the page was last modified (you will need to use the yyyy-mm-dd format).
The changefreq tag indicates the average change frequency of the page. You can choose between hourly, daily, weekly, monthly and yearly – or never for archived URLs.
The priority tag indicates the relative priority of this page with regards to your other pages. The default priority is 0.5, and the range goes from 0.0 to 1.0, the latter indicating highest priority. Don’t waste your time assigning 1.0 to all your pages, as the priority is and only used to differentiate between pages in this sitemap.
Validating Your Sitemap
It’s a good idea to validate your sitemap after you’ve created it, to ensure that it is error-free. There are plenty of online tools which can check the validity of your file, for example here.
Alternatively you can use Google Webmaster Tools to test your XML sitemaps. When you click the ‘add/test sitemap’ button under Crawl > Sitemaps, you can test a sitemap prior to submitting it.
Informing Search Engines
Now that you have created and validated your sitemap, it’s time to inform search engines about it.
You can inform Google and Bing about the location of your sitemap via their Webmaster Tools. For Google; log into your account and go to Crawl > Sitemaps as in the image above. On the right hand side you’ll see the ‘add/test sitemap’ button. Simply add the URL of your sitemap and you’re done. In Bing Webmaster Tools, look for the Sitemap Widget and click ‘submit a sitemap’. Here you can enter the location of your sitemap.
You may also want to add the URL to your robots.txt file. All you have to do is add an extra line to your file:
And simple as that, you’ve created and submitted your XML sitemap. If you have a lot of images and/or videos on your site, you can create specific sitemaps for those as well. We’ll dive into other kinds of sitemaps over the following weeks, so stay tuned.