How to Generate an XML Sitemap
By Christian Bullock on July 6, 2018
XML Sitemap defined: A “cheatsheet” for search engines to see all of the 200 OK URLs that you want to have in their indexes for your domain.
This file gives search engines access into every single URL you want to have ranked for your domain in a way that doesn’t make search engines rely on their spiders or crawlers find them all.
An XML sitemap file is almost always present at the root of a domain (e.g. example.com/sitemap.xml).
XML Sitemap Use Cases
You should always have an updated XML sitemap readily accessible for search engines to grab. However, there are circumstances where you need to pay some extra attention to this all-important file:
- Site migration – If you’re changing URL structures, when these changes are pushed live you should have your XML sitemap file reflect the new URLs.
- News – If you’re generating news at a fairly frequent clip, you should ensure your XML sitemap updates with these new URLs. Also look into a Google News XML sitemap.?
- International – Each international “version” of your site, whether it’s on a subdomain or a subfolder, should have its own XML sitemap file.?
Special Considerations for XML Sitemaps
The following are some things you should keep in mind when thinking about creating an XML sitemap:
- One XML sitemap per domain. This means if you have a subdomain (subdomain.example.com), you would need to create an XML sitemap for that subdomain only and place it at the root (subdomain.example.com/sitemap.xml).
- URL limitations. If you have more than 50,000 URLs, you need to create separate XML sitemaps. In this case, you would create a parent XML sitemap file (sitemap-index.xml) and then have this file link off to each sitemap XML file (sitemap1.xml, sitemap2.xml). This content is more for site owners who have a website with less than 50,000 URLs. If you do, you can consult the XML sitemap website with instructions on this practice here.
- International. If you have International content, such as a version of your site on a subfolder level (example.com/es/), you would want to create an XML sitemap for this “section” of the site and place it at that subfolder level (example.com/es/sitemap.xml).
XML Sitemap Example
These files are always constructed in the same way, a protocol that all search engines agree and follow.
<url> <loc>The URL “location” (https://www.example.org). The only critically important element to have. <lastmod>The last time the page content has changed. Moderately important to include. Should follow this format: YEAR-MM-DD (2018-07-03). <changefreq>How frequently will the page content change. Slightly important to include. Values you can use are: + always + hourly + daily + weekly + monthly + yearly + never <priority>A scale from 1.0 to 0.0 on how much “value” you believe each page has. Slightly important to include. You would likely follow the URL structure of your website in deeming importance, such as: + example.org - 1.0 + example.org/page/ - 0.9 + example.org/page/another-page/ - 0.8 </url>
So an example of two URLs in a sitemap file would look something like this:
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>https://www.example.org/</loc> <lastmod>2018-07-03</lastmod> <changefreq>daily</changefreq> <priority>1.0</priority> </url> <url> <loc>https://www.example.org/page/</loc> <lastmod>2018-07-03</lastmod> <changefreq>weekly</changefreq> <priority>0.9</priority> </url> </urlset>
You add the top lines to show this is an XML sitemap example and you add the trailing slash urlset to signify the end of the file.
XML Sitemap SEO Importance
Like previously mentioned, XML sitemaps are cheatsheets for search engines. You can easily tell them to go out and crawl the listed URLs without having to rely on their spiders to find them all.
This can be both a blessing and a curse, whether your XML sitemap is up to date :)
We find that there is still some SEO value in having an up-to-date, maintained XML sitemap. While search engines (and their spiders) are getting smarter at finding all of the content for a domain and being able to crawl all types of content, why not give them a list of your URLs?
How To Generate an XML Sitemap File - WordPress
If you’re using the WordPress platform, a whole slew of plugins give you the ability to create an XML sitemap for your website.
Perhaps the most popular way is by using the Yoast plugin. This plugin will also update your XML sitemap whenever any new content is posted on your site - automagically.
How To Generate an XML Sitemap File - Other Platforms (Static, Wix, etc.)
Never fear! If you’re using a CMS other than WordPress, there are still ways you can create and maintain an XML sitemap.
Our most-trusted tool is XML-Sitemaps. This online tool will crawl and grab all of your URLs and automatically generate an XML sitemap. The limitation here is that the free version will only crawl up to 500 URLs.?
You can also use other tools to create XML sitemaps, such as Screaming Frog SEO Spider.
Checking and Validating Your XML Sitemap
So you’ve created an XML sitemap file. Great! Now you should check and see if you did it right ?
Google Search Console and Bing Webmaster Tools, the two places you should submit your XML sitemaps to if you have a primarily US-based website, offer input on whether they can “read” your sitemap files.
After validating your website, you’ll be able to have the option of giving each website your XML sitemap file URL address. When doing so, we recommend having them report to you about any errors they might be seeing. Maybe you didn’t close a tag properly. Or misspelled one of the labels. In any event, you want to make sure the validation comes back error free.
Submitting an XML Sitemap File to Google and Bing / Yahoo
Google Search Console and Bing Webmaster Tools are the two destinations for you to navigate to in order to submit your file to search engines. If you followed the checking and validating instructions, you’ll be able to access these two sites to submit your XML sitemaps to each search engine.
Note that Bing Webmaster Tools includes both Bing and Yahoo search indexes.
These two destinations will also alert you to any issues in the future if they find any URLs in the XML sitemap returning 4xx errors or redirects. It’s a good idea to check up on the health of these files in both places on a weekly basis.
We hope you’ve learned a little bit more about XML sitemaps, why they’re important, and how to generate and submit these files to search engines. Have questions? Tweet at us and we’ll get back to you!