WordPress: XHTML Sitemap Generator Template

As a Webmaster, one of the things you always need to be aware of is how well your the pages of your site are interlinked. This is a crucial factor in overall search engine performance, and simply assuming that your architecture is robust enough to handle this is definitely not the route you want to […]

As a Webmaster, one of the things you always need to be aware of is how well your the pages of your site are interlinked. This is a crucial factor in overall search engine performance, and simply assuming that your architecture is robust enough to handle this is definitely not the route you want to take. Over time, you will likely accumulate tons of pages, and as this happens, the odds of certain pages getting buried to the point of becoming nearly inaccessible tend to go up. To combat this, you can generate an XHTML sitemap that contains links to every page of your site.

Typically, WordPress archive pages (and other CMS archive pages, for that matter) do not contain links to all of your internal Pages and available syndication feeds. On top of that, most archives also fail to link to every Post.

Why? Because Google Said So

In its Webmaster Guidelines, Google touts the merits of adding a sitemap to your site.

  • Make a site with a clear hierarchy and text links. Every page should be reachable from at least one static text link.
  • Offer a site map to your users with links that point to the important parts of your site.

How to implement?

  1. Download XHTML Sitemap Generator, and extract on your local folder.
  2. Upload sitemap.php to your active WordPress theme directory.
  3. In your WordPress administration panel, go to Write Page.
  4. Fill in an appropriate Page title, and leave the text area of the post empty. Fianlly, create a Post Slug called “sitemap.”
  5. Select Sitemap template from the Page Template dropdown box on the siderbar.
  6. When you’re done, click on Create New Page.

Note: The resulting page will be stripped of all styles, so there will be a bit of a visual disconnect between the sitemap and the rest of your site.

Page Styling!

If you want your new sitemap to blend nicely with the rest of your site, here’s what you need to do:

  1. Open up your page.php file from your current WordPress theme, and save it as new_sitemap.php.
  2. In the new_sitemap.php file, delete all the code that lies between the under given lines:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    and this one:

    <?php endwhile; endif; ?>

  3. Open sitemap.php file (download it here), and copy all of the code that lies between the opening and closing <body> tags.
  4. In the new_sitemap.php file, paste the code that you just copied in between the two lines of code indicated in point #2.
  5. Finally, in the new_sitemap.php file, add this code at the very top of the file:

    &lt;?php<br />/*<br />Template Name: New Sitemap<br />*/<br />?&gt;

  6. Save new_sitemap.php and upload it to your server.
  7. Follow the instructions above, except in step #4, choose the New Sitemap template.

personified

WordPress XHTML Sitemap Generator Template