Even though the term “XML sitemap” leaves little to the imagination, not everyone understands it. Or, even if they know what sitemap represents, they may not understand what XML stands for, and what purpose the terms serve together. We’re here to tell you not to stress it too much. After all, WordPress developers have you covered as long as you’re using WordPress 5.5+. Even if you aren’t, your internal link structure unquestionably took over the role, albeit not as efficiently. Regardless of all that, learning how to add an XML sitemap in WordPress has merit. Let’s begin.
What is an XML sitemap?
An XML sitemap is a file on your website that contains a detailed outline of all its pages, written and sorted in a format compliant with Extensible Markup Language (XML). Its purpose is to list the aforementioned information in an easy-to-read format, allowing search engine bots to quickly and efficiently find and index your website content. The tags next to URLs also tell search engines what the last time a page was updated is and how often it gets updated. Additionally, it can rank every URL on a priority scale, letting crawlers know which pages are more important than other URLs.
Reasons to add an XML sitemap
Even if you never create a sitemap, crawlers will still create a list of your website pages. However, as mentioned, they rely on internal links, meaning that some crawlers may never reach some pages on your website. Additionally, they’ll finish the job drastically slower, which means they’d visit your website less often, and take longer to detect updates. To sum it up, adding XML sitemaps does the following:
- Allows crawlers to frequently, thoroughly, and quickly list your pages.
- Lets bots know about pages that were, unbeknownst to you, left unindexed.
- Has the potential to place you higher on the SERPs (search engine page results) thanks to a clear hierarchy and structure of pages.
- Indirectly tells search engine your website is user-friendly, active, and provides things of value.
- Lets you add extra information, such as whether a page contains different language editions.
1. Access the XML sitemap in WordPress directly
Like we mentioned if your website is using WordPress 5.5 or later, an XML sitemap was generated by default. Granted, it is very rudimentary and lacks the advanced tags we mentioned below. It’s also hard to manage which code is added or removed since its primary purpose is to help new website owners avoid the drawbacks of its absence. With that said, you can check it in 2 ways:
- View it in browser: Open “https://ww.your-website.com/wp-sitemap.xml”.
- Edit it: Access your website via FTP. Search for “wp-sitemap.xml”. Right-click and select View/Edit.
2. Create an XML sitemap for WordPress manually
Don’t feel like updating WordPress or the default XML sitemap feels too basic? No problem! You can do it yourself, although you must also add an entry for every new page you make public. We’ll start by demonstrating how an XML sitemap with one URL looks:
?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/09"> <url> <loc>http://www.your-website.com/page-name</loc> <lastmod>2021-09-29</lastmod> <changefreq>weekly</changefreq> <priority>0.6</priority> </url> </urlset>
What do these tags mean?
Half of the tags are mandatory, while the rest are optional. Starting from the top, the required tags are the following ones:
- <urlset> represents the latest sitemaps protocol in use (0.9/09). You can visit “http://www.sitemaps.org/schemas/sitemap” to see the folder contents.
- <url> is simply a parent tag that defines URL location and optional tags.
- <loc> is a mandatory tag that refers to the URL of the page. Must contain “https://” and “www” if your website uses it. It must also be under 2048 characters.
These tags should be added to improve SEO, but don’t have to be present:
- <changefreq> tells search engines how frequently you plan to update the article. Values: always, never, hourly, yearly, weekly, monthly.
- <lastmod> lets search engines know the data of the last edit (YYYY-MM-DD).
- <priority> defines priority on the range of 0.0 to 1.0, with the default being 0.5.
Adding multiple URLs
The code above is an example of one URL, but you’ll use tens or even hundreds. Since they’ll use the same character set and sitemap protocol, you merely have to list them inside <url> tags. Otherwise, you must create a separate sitemap file, then create a “master” sitemap that links them together, which is another thing entirely. Here’s an example:
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/09"> <url> first URL </url> <url> second URL </url> </urlset>
Upload it to your website
Here’s how uploading an XML sitemap to a WordPress works:
- Open any text editor, e.g., Node or Notepad, and paste the code.
- Choose any name before adding a .xml file extension, e.g., sitemap.xml.
- Reach your WordPress website root folder via FTP (check the method above).
- Delete any existing sitemap files.
- Upload the file you made to the root folder.
- Access the sitemap via browser to check, like in method 1.
- Optional. Run the page through any “XML sitemap validator” website to double-check there are no errors.
3. Generate an XML sitemap using external tools
It would be ludicrous to manually create a sitemap with hundreds of URLs, let alone keep it updated. The maximum is 50,000 URLs per sitemap file – let that sink in. To save time and effort, we suggest you:
- Search for an “XML sitemap generator”.
- Pick any website – they work on the same principle.
- Enter your website URL and download the generated file.
- Make changes manually (if needed) before uploading as we showed in method 2.
4. Add XML sitemap in WordPress via a plugin
Another way to both generate an XML sitemap and keep it up-to-date automatically is to install a WordPress plugin. But before you start searching for a dedicated plugin (although you can), we recommend testing one you likely already have: Yoast SEO. Here’s how enabling XML sitemap via YoastSEO works:
- Click on SEO in the left sidebar of the WordPress Admin Section.
- Choose General when the list expands.
- Switch over to the Features tab.
- Scroll down to “XML sitemaps” and toggle it on.
- Click on Save changes.
- You can see it in action by:
- Clicking on the question mark icon > See the XML Sitemap.
- Visiting “https://www.your-website.com/sitemap_index.xml” in your browser.