Guide to Sitemaps

Regnant

Game Owner
Sitemaps help search engines index pages of your site. It’s a very nice addition to any SEO practice! Every sitemap has the same structure to it, and I’d suggest including both pages and images. 

Sitemap Set-Up

Create an empty XML file (most people call it sitemap.xml) and insert the following.

Top Wrapper

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">


Bottom Wrapper

</urlset>


Every page will then have it’s own code within those tags.

Example page:

<url>
<loc>https://ohudogs.com/</loc>
<changefreq>monthly</changefreq>
<lastmod>2017-04-12</lastmod>
<priority>1</priority>
</url>


The only required item required for each page is loc, which is the URL of the page you want your search engine to find. 

changefreq is how often the page should be re-crawled for new content. The options for this are:

  • always
  • hourly
  • daily
  • weekly
  • monthly
  • yearly
  • never
lastmod is when the page was last changed, sort of similar to changefreq in how a search engine will use it. If you are using changefreq, you probably don’t need to use this. It may be nice to put on your news overview page though and update it whenever there's a new post!

priority is how important a page is compared to others, on a scale of 0.0 to 1.0. When a search engine is showing results and it gets to your site, it may use the priorty to choose which page to show. Homepage and registration should probably be set at 1, with other pages set less than that. The priorty is relative, so setting everything to 1 is the same as setting everything to 0.

A completed sitemap might look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://ohudogs.com/</loc>
<changefreq>monthly</changefreq>
<priority>1</priority>
</url>
<url>
<loc>https://ohudogs.com/about/</loc>
<priority>0.5</priority>
</url>
<url>
<loc>https://ohudogs.com/register/</loc>
<priority>0.8</priority>
</url>
</urlset>


Images

Want your images to show up in searches too? You can add images to a sitemap in the same way! You can either have these in the same sitemap, or create a separate one. You can submit more than one sitemap to search engines.

<url>
<loc>https://ohudogs.com/imgs/dogs/gin.png</loc>
</url>


PHP Sitemap

If you have a lot of pages, or a lot of images, it be nice to automate your sitemap. Instead of an XML page, create a PHP page with an XML header.

Below is an example of a PHP image sitemap, that’s grabbing all images from a imgs/dogs folder.

<?php header('Content-type: application/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$imgs = scandir('imgs/dogs');
foreach ($imgs as $img) {
    if (strlen($img) > 4) {
        echo '<url>
          <loc>https://ohudogs.com/imgs/dogs/'.$img.'</loc>
        </url>';
    }
}
echo '</urlset>'; ?>




Search Engines

robots.txt

After you have your sitemap made, add it to your robots.txt file with the following line.

Code:
Sitemap: https://ohudogs.com/sitemap.xml
Google Search Console (aka Webmaster Tools)

To submit your sitemap to Google, login to your Google Search Console account, select your site, and then go to Crawl --> Sitemaps. In the upper right hand corner, you should see a Add/Test Sitemap button

View attachment 268

Bing Webmaster Tools

Hey it’s a free tool, might as well get those people using Bing too! Login, click on your site, and scroll down to Sitemaps, and click the “Submit a Sitemap” button.

View attachment 269

 
Back
Top