Let’s start with this example, using WordPress and XML sitemaps properly.
Now one thing. Let’s FOLLOW how the search engines work here.
You need to tell them where your sitemap.xml file lives.
Where do you first reference it? In the ROBOTS.TXT file
Looks like this:
User-agent: * Sitemap: https://YOURDOMAIN.com/sitemap.xml
OR if you use Yoast SEO, you may have several sitemaps that are then combined into one for Google, however you can organize things a lot nicely with this feature and there are a few quirks, but I will explain how they work in the next section.
That would look like this:
User-agent: * Sitemap: https://YOURDOMAIN.com/sitemap_index.xml
EITHER WAY is fine, it’s just important that you reference the sitemap, whatever you name it, in the
file and then submit the correct name to Google’s Search Console. You will get errors if you do it wrong.
TRAILING SLASH ISSUE
This is pretty cool. So you know that it’s best to have your pages consistent. I just simply have a ‘/’ or ‘Trailing slash’ at the end of all urls that don’t end in an extension, such as .html
Sometimes, when you create products that have product-categories or pages and post with both page and post categories, you will then sometimes find yourself with a ‘product-cat_sitemap.xml’ that has some entries without trailing slashes. Even if you have the page properly going to a URL with the slash, if the SITEMAP has one without, its going to be considered a little different.
The solution? use the Yoast SEO plugin.