The URLs you use in your Sitemap should be the same canonical URLs you use on your site. If you include a trailing slash when linking between your pages then include a trailing slash in your site. Whether URLs end with a trailing slash is generally up to you - there isn't necessarily any right or wrong way of doing it.
If your URLs map directly to files on the filesystem then arguably they should only have a forward slash at the end if you are linking to a "directory" and your page is the default document within that directory eg. index.html
, index.php
, etc. But this should also be how you link to the page within your site. The forward slash is simply to avoid any ambiguity, to indicate it is a directory and not a file. (By default on Apache, if you link to a file system directory and omit the trailing slash then mod_dir triggers a 301 external redirect to append a trailing slash - to "fix" the URL.)
For example, it is generally preferred to not link to the default document in the directory:
http://www.example.com/path/to/index.html
You should simply show the URL as the following (with a trailing slash):
http://www.example.com/path/to/
As mentioned, the trailing slash removes any ambiguity. If you omit the trailing slash, it will probably still work, but it first looks for a file called to
before realising it's a directory.
The URLs in the sitemap example at the address given do not have a forward slash at the end because they are linking to specific HTML files on the filesystem, eg. http://example.com/foo.html
. In this case, if you simply append a trailing slash it will likely generate a 404 Not Found response on Apache. (Because the text/html
handler does not accept path_info by default.)
Incidentally, this relates more to how you link to files within your site - not just the Sitemap.