Sitemap Guide - Create a Sitemap for a Website

Published:

|

Updated:

Are you wondering what a website sitemap is and how to create one for your website? Read on to find everything you need to know about website sitemaps.

In this complete guide to sitemap, you'll learn what a sitemap is and how to create and submit your sitemap file to Google Search Console for search engine indexing.

You'll also gain an understanding of sitemap best practices and some of the common sitemap formats like HTML and XML sitemaps.

Let's get started.

Sitemap Guide - Create a Sitemap for a Website

Introduction to Sitemaps

A sitemap is a list or file that lists all your website links or pages that are usually crawled by search engines like Google or Bing.

This helps Google (or other search engines) to better understand your website content, such as how many pages, videos, and images are on your website.

As a result, this allows search engine crawlers to efficiently read and go through the URLs in your sitemap for better site indexing in the search results.

Generally, a sitemap file is created for web search crawlers, but it can also be consumed by humans.

Read below to find out different types of sitemap formats and which ones you need for your site.

Sitemaps Are Not robots.txt File

Note that a sitemap isn't a Web Robots or robots.txt file.

A robots.txt file helps instruct web crawlers — such as the Google search crawler — on which site URLs to crawl or avoid.

Read about robots.txt in detail in this Moz article.

Types of Sitemaps

Sitemaps come in different formats depending on the target audience. An HTML sitemap is convenient for humans, while an XML sitemap is recommended for search engines.

Each format has its pros and cons, along with specific requirements. For instance, a plain text sitemap must be UTF-8 encoded.

XML Sitemap

XML (Extensible Markup Language) is the standard and common format when it comes to submitting your sitemap to Google and other search engines.

They are the most flexible and can provide additional information about website pages when compared to other formats.

Therefore, it's generally recommended to use XML sitemap for your websites and apps.

HTML Sitemap

An HTML (HyperText Markup Language) format is ideal if you want your site visitors to visualize the overall site linking structure and facilitate ease of navigation.

Today's web crawlers are smart and should be able to correctly understand and index HTML sitemaps.

However, it's a good practice to stick with the XML format to ensure greater versatility when it comes to site links.

Plain Text File Sitemap

You can also use a plain text file format (.txt) to generate a sitemap for your site using any plain text editor like Windows Notepad.

Syndication Feed Sitemap

RSS (Really Simple Syndication) feeds like RSS 2.0 or Atom 1.0 feeds can also be used to build a sitemap; however, they aren't that common as compared to XML formats.

The sitemaps.org protocols suggest using this format only if your site already has a syndication feed.

In the next section, you'll learn what an ordinary XML sitemap looks like.

Example of an XML Sitemap

Here's an example of a sitemap index file of W3Things:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://w3things.com/newsletter/</loc>
    <lastmod>2023-12-06T00:00:00Z</lastmod>
  </url>

  <url>
    <loc>https://w3things.com/products/essential-gulp-kit/</loc>
    <lastmod>2023-12-08T00:00:00Z</lastmod>
  </url>
</urlset>

In the next section, I'll explain each XML attribute and the required ones you need to create your sitemap.

Sitemap Structure Guide

If you want search engine crawlers to read and provide better SEO results for pages on your website, ensure that you follow the required sitemap structure as mentioned below.

XML Declaration

Each XML sitemap must have the XML declaration at the top of the file to provide the correct XML version and character encoding. This helps XML parsers correctly interpret the XML file and other related information. You need to declare this only once in the file.

Usage example:

<?xml version="1.0" encoding="UTF-8"?>

urlset Attribute

The <urlset> attribute is required. It allows encapsulation of the file and defines the current protocol standard.

There should only be one instance of this present in the file.

Usage example:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  ...
</urlset>

url Attribute

The <url> attribute is required. It defines each URL or link of the website.

This is the parent attribute which encompasses several other attributes as mentioned below.

Inside each <url> attribute, the <loc> attribute is required. Read below to learn more.

Usage example:

<url>
  <loc>https://w3things.com/blog/</loc>
</url>

loc Attribute

The <loc> attribute is required. It must be present inside each <url> attribute.

It specifies the URL of each page of your website.

Usage example:

<url>
  <loc>https://w3things.com/blog/</loc>
</url>

The following attributes are optional, and you may ignore them if your website doesn't require them.

Note that the interpretation of each attribute depends on the search engine.

For example, Google ignores both the <priority> and <changefreq> attribute values. However, other search engines like Microsoft Bing or DuckDuckGo may utilize these when indexing your website.

Refer to the documentation of the relevant search engine if you plan to add support for it.

In any case, it wouldn't hurt your site to have all these optional attributes present in the sitemap.

lastmod Attribute

The <lastmod> attribute is optional. It specifies the last modification date of the webpage.

However, search engines may interpret this differently. For instance, Google ensures that the value of <lastmod> is consistently accurate and verifiable by checking the last modification of the webpage.

The date should be in ISO-8601 format (YYYY-MM-DD). The value of time is optional.

Usage example:

<url>
  <loc>https://w3things.com/blog/</loc>
  <lastmod>2024-01-01T00:00:00Z</lastmod>
</url>

changefreq Attribute

The <changefreq> attribute is optional. It specifies how often the web page is likely to change.

The following are the valid attribute values:

  • always
  • hourly
  • daily
  • weekly
  • monthly
  • yearly
  • never

Again, the exact interpretation of this attribute may vary by search engines.

Usage example:

<url>
  <loc>https://w3things.com/blog/</loc>
  <lastmod>2024-01-01T00:00:00Z</lastmod>
  <changefreq>weekly</changefreq>
</url>

priority Attribute

The <priority> attribute is optional. It specifies the priority or importance of each URL relative to other ones on your site — allowing you to instruct web crawlers that certain pages are more important.

The value should be between the range of 0.0 and 1.0. A default priority value of 0.5 is assigned to all URLs.

Usage example:

<url>
  <loc>https://w3things.com/blog/</loc>
  <lastmod>2024-01-01T00:00:00Z</lastmod>
  <changefreq>weekly</changefreq>
  <priority>1.0</priority>
</url>

Refer to the Protocol page of the sitemaps.org website to learn about all the attributes in detail.

Sitemap Best Practices

To ensure that your website sitemap is effectively crawled by different search engines, you should follow all the best practices as outlined by the sitemaps protocol website.

You may also refer to this documentation by Google Search Console for more information about the recommended practices.

Below, I've briefly mentioned a few recommended practices for creating an XML sitemap.

  • File size and URL limit: Sitemaps must be 50 MB in file size and must not have more than 50,000 URL entries.
  • File encoding type: Sitemap files must be UTF-8 encoded.
  • File location: Sitemaps must be present in the root directory of your website to ensure all the URLs can be included and crawled.
  • Absolute URLs: Absolute URLs must be used to ensure correct crawling by search engines.
  • Entity escaping: All URLs must be entity escaped.

Create a Sitemap

Now that you've learned the basics of a sitemap, let's learn how to create a sitemap for content on your site.

How you create a sitemap index file largely depends on the structure of your website as well as the number of URLs present on your site.

It also depends on whether your site is managed by a platform like Wix or running on one of the Content Management Systems (CMS) like WordPress.

Below, I've outlined some common methods for generating your sitemap and submitting it to Google.

Build a Sitemap for a WordPress Website

If you're using WordPress CMS for your site, you'll need to use one of the SEO plugins like Yoast or Rank Math.

These SEO plugins automatically generate an HTML sitemap for your WordPress site in addition to providing website SEO enhancements and features.

Generally, you only need to install and activate the relevant SEO plugin, and it'll automatically add a WordPress sitemap.

Still, it's advised to refer to plugin docs to find details about the sitemap generation method.

For Rank Math sitemaps, refer to this knowledge base article.

For Yoast sitemaps, refer to this article.

Make a Sitemap for a Custom Website

If you're using a custom-coded website that is developed using a specific JavaScript framework like Next.js or Vue.js, refer to the relevant framework documentation on how to properly set up automatic sitemap generation for the pages on your site.

Here's Next.js documentation on XML sitemaps.

The same is applicable if your site is built using a Static Site Generator like 11ty or Gatsby,

Using Eleventy Static Site Generator?

Bonus: To save you the trouble, I've put together a detailed tutorial for creating an XML file using 11ty here.

Manually Create a Sitemap

If your site is small and has a few dozen URLs, you may manually create a sitemap. This would make sense if your site is hand-coded using the old-school HTML static files method.

For this, use any plain text editor like Windows Notepad. Simply follow the required sitemap structure as described above and you'll be good to go.

However, if you'd rather not manually create one, you can use a sitemap generator. Refer to the next section to learn more about that.

Use a Sitemap Generator for Website Sitemap

You may use an online sitemap generator if you need a sitemap for pages on a website but don't want to manually create one for any reason. As a benefit, this method also prevents any potential mistake that would occur if you were to manually create one.

One such widely used generator is XML-Sitemaps. The free plan allows you to quickly and easily generate a sitemap for any site.

Review Your Sitemap

After you've built your sitemap, review it to ensure that all pages are included in it.

Depending on your site, you may want to exclude certain pages — such as 404 error pages, confirmation pages for newsletter subscriptions, and other similar pages.

Submit Your Sitemap to Google Search Engine for Better SEO Results

Once you've created the sitemap for your site or app, you need to submit your sitemap location in Google Search Console if you want to track its performance.

I'll assume you've already added and verified your site in Search Console. If not, you need to do that first before submitting your sitemap to Google.

Log in to your Google Search Console account and select the relevant website property from the property selection drop-down menu.

Next, navigate to the Sitemaps page under the Indexing sidebar menu.

Finally, copy and paste the full URL of the sitemap.xml file in the Add a new sitemap section and click on the Submit button to confirm.

Submitting website sitemap to Google Search Console.
Submitting website sitemap to Google Search Console.
View Original Image Size

Once submitted, Google Search Console will notify you if there are any issues — such as crawling or accessing your sitemap — and provide the relevant troubleshooting fixes as applicable.

For detailed instructions, refer to this Google Search Console help page.

Conclusion

That's it! You learned everything you needed to know about making effective and correct sitemaps for your websites and applications.

If you need help creating a sitemap for your website or app, feel free to contact me on Facebook or via email at [email protected] and I'd be glad to help you with whatever you need.

And before you leave, did you know that you might need a CSS reset stylesheet for your website? Learn everything you need to know about CSS resets in this detailed guide.

Frequently Asked Questions about Website Sitemaps

How do you structure a sitemap?

The valid structure of a sitemap is crucial for the proper interpretation and crawling by search engines.

Refer to the Sitemap Structure Guide section above to learn how to structure your sitemap.

What should be included in a sitemap?

All the pages that you want to be indexed by search engines like Google or Bing should be included in your sitemap.

However, certain pages — like 404 error pages or privacy policy pages — should be excluded to prevent thin or duplicate content issues.

Ultimately, it mostly depends on your site structure and requirements.

How do I make a good sitemap?

To make a good sitemap, ensure you follow all the best practices of a good sitemap as mentioned in the guide above.

Furthermore, ensure your sitemap structure is valid and correct.

Read the complete guide above to learn more about making a good sitemap.

Additional Resources

Here are some links to additional content if you're interested:

Contents

    Danial Zahid's headshot.

    About Danial Zahid

    I'm a self-taught web developer passionate about everything related to websites and web development. Over the past years, I've explored and worked with different web technologies and tools, notably WordPress, Eleventy, npm, and Gulp.js, to name a few.

    In addition, I've created and currently maintain several open-source projects, including web apps, widgets, websites, and more.

    When I'm not writing content for W3Things or doing web development work, I enjoy my free time by playing games or listening to podcasts.

    Get Essential Gulp Kit

    The ultimate Gulp.js solution to improve your developer experience.

    • Includes complete Gulp.js toolkit setup
    • Optimize website content and static assets
    • Continuous asset optimization during development phase
    • Optimize unlimited number of files in bulk
    • Plus many more awesome features

    Subscribe to the Newsletter

    This website uses cookies to optimize your site experience. By continuing to use the site, you are agreeing to its privacy policy and the use of cookies.