This article is going to examine HTML user sitemaps for WordPress. In particular, I am going to explain how to create a user sitemap page template within your WordPress theme. But, before we get that far, we are going to cover what they are and how they impact SEO.

What is a User Sitemap

First, lets start with a traditional sitemap, which is in XML format. These sitemaps provide directions for search engine crawlers to crawl and index your website.

What about humans? We want to be able to provide our human users with the same ease of use, right? A user sitemap, therefore, is a page with a clean design, that breaks down the contents of your website. Site visitors can use it to drill down to the content they are looking for.

For example, you can find this site’s user sitemap here. Likewise, the XML sitemap for search engines is here. Go ahead and take a look at both, and you’ll see one is user friendly and the other is not.

At the root, an HTML user sitemap is super simple. It is just a plain text page outlining your site’s most important areas, with links to them. It makes usability better, and keeps things organized.

The usability factor contributes towards good SEO, and we’ll get into that in the next section.

User Sitemap Impacts on SEO

Why do SEOs love the farmer’s market? Because there’s lots of organic content there. Ha, dumb joke.

When you get down to it, the point of SEO is to make the web more accessible. Google has made its mission to clean up the internet landscape and guide searchers towards great information. And really, towards what they are looking for. People are curious. Whatever it is you write about, someone is probably looking for it, so SEO matters.

HTML user sitemaps fall within the realm of on-page SEO. That is, structural factors within a page that help it get indexed by Google, and then served to searchers. When you look at a list of on-page ranking factors, they boil down to one thing: the user experience (UX). If something on a page is not useful to the user, then it doesn’t need to be there. Does mobile friendliness create a better UX? Yep. Do meta descriptions help people find relevant things on result pages, and therefore provide a better UX? Heck yea.

Both of those examples are official ranking factors for Google, as are other on-page optimizations. One could relate then, that ranking factors are determined by whether or not a variable improves the UX.

So do you think that a page in which all site information is categorically indexed for users to reference might make a better UX? I certainly think so. One could argue that Google does too. If users can access content more easily, they will spend more time with it. Website dwell time is something that is beginning to gain momentum as a ranking factor.

Dwell time is the amount time it takes a user to return to a search result page from your website. The longer the time frame, the more content they presumably consumed. You can read more about the impact of Dwell time on SEO in this Moz article: The Two User Metrics that Matter for SEO.

The relationship I am drawing here, is this: user sitemaps improve UX and help content discovery. Greater content discovery equals higher engagement. Higher engagement equals greater dwell time. Longer dwell time factors into SEO ranking.

Alright. So that’s settled. Let’s go make an HTML user sitemap, shall we?

 

Plugin Method

First off, there is a plugin for this. Just like there is for everything. If you’d rather use a plugin, I suggest Page-List. It enables you to create a list of pages on your site and then drop it into a page using a shortcode. Nifty.

But, sometimes we don’t want to use a plugin if its not necessary. Having a lot of plugins installed can bloat the system and slow it down. We don’t want that.

Also, this plugin has some downsides. For instance, it won’t handle custom post types. And, well, that’s it. But that’s a big deal. Many business websites are going to be utilizing custom post types and that is something we don’t want excluded from the user sitemap.

 

Create a User Sitemap Page in WordPress

What we are going to do here is create some PHP files within our WordPress installation to make our own user sitemap:

Step 1: Via FTP or cPanel, access your WordPress site’s root folder.

Step 2: Locate your theme’s folder and open it. Most likely in “wp-content/themes.”

Step 3: Hunt around and find the folder containing your theme’s page templates.

Step 4: Open it and create a new PHP file. Name it “sitemap.php.

Step 5: Paste the following code into this file:

<h2 id="pages">Pages</h2>
<ul>
<?php
// Add pages you'd like to exclude in the exclude here
wp_list_pages(
  array(
    'exclude' => '',
    'title_li' => '',
  )
);
?>
</ul>

<h2 id="posts">Posts</h2>
<ul>
<?php
// Add categories you'd like to exclude in the exclude here
$cats = get_categories('exclude=');
foreach ($cats as $cat) {
  echo "<li><h3>".$cat->cat_name."</h3>";
  echo "<ul>";
  query_posts('posts_per_page=-1&cat='.$cat->cat_ID);
  while(have_posts()) {
    the_post();
    $category = get_the_category();
    // Only display a post link once, even if it's in multiple categories
    if ($category[0]->cat_ID == $cat->cat_ID) {
      echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
    }
  }
  echo "</ul>";
  echo "</li>";
}
?>
</ul>

Note: You will notice I left out Authors and included only Pages and Posts. This was intentional. For one, this keeps things simple. Two, adding your authors can redirect viewers to pretty permalink enabled pages that expose usernames leaving you open to user enumeration vulnerabilities.

Step 6: If you need to include custom post types in your user sitemap, add this code below the other code:

foreach( get_post_types( array('public' => true) ) as $post_type ) {
  if ( in_array( $post_type, array('post','page','attachment') ) )
    continue;

  $pt = get_post_type_object( $post_type );

  echo '<h2>'.$pt->labels->name.'</h2>';
  echo '<ul>';

  query_posts('post_type='.$post_type.'&posts_per_page=-1');
  while( have_posts() ) {
    the_post();
    echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
  }

  echo '</ul>';
}

Step 7: Log into WordPress and create a new page. Set the page template as “sitemap,” name the page “Sitemap” and publish.

 

And there’s your sitemap.