EN / ZH
Creating a Sitemap for Your WordPress Blog

Have you noticed that many WordPress blogs have a sitemap link at the bottom? Clicking it reveals the site’s categories and content structure. So what exactly is a sitemap good for?

For WordPress blogs, the most commonly used sitemap is generated by the Google XML Sitemaps plugin. It’s arguably one of the best sitemap plugins out there. However, this type of sitemap is meant for search engine crawlers, not for human readers. So I’ve gathered some methods for creating reader-friendly sitemaps.

1. Using the Dagon Design Sitemap Generator Plugin

Plugin official page: http://www.dagondesign.com/articles/sitemap-generator-plugin-for-wordpress/

  1. Install and activate the plugin
  2. Enable it in the WordPress admin panel
  3. Set the Language to Chinese (or your preferred language) for easier customization — unless your English is excellent!
  4. Find the page template (page.php), copy it, and rename it to “sitemap.php”
  5. Open “sitemap.php” and add the following at the very first line:
<?php /*Template Name: Sitemap*/?>
  1. Create a new page titled “Sitemap”. In HTML editing mode, enter: <!-ddsitemapgen-> (Be very careful with the syntax — even an extra space could cause display issues). Select the page template as Sitemap.
  2. In sitemap.php, find the following code:
<?php the_title(); ?>

Then add this code after it:

<?php echo ddsg_create_sitemap(); ?>
  1. Finally, visit https://imzl.com/sitemap to view your sitemap.

2. Using the Dagon Design Sitemap Generator Plugin (Simplified Method)

The approach is similar to the one above, except you don’t need to modify page.php.

  1. After configuring the plugin settings, create a new page with the URL set to http://www.xxxxx.com/sitemap
  2. In HTML mode, enter <!-ddsitemapgen-> and save.

3. Building a Sitemap from Scratch

  1. Download page.php from your current WordPress theme and rename it to sitemap.php. Add this at the top of the file: <?php /* Template Name: Sitemap */ ?>

  2. Copy the code I’ve provided below and paste it between these two lines:

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

//Insert the provided code here (shown below, just copy and paste)
 <?php endwhile; endif; ?>

Here’s the code:

<h2><?php the_title(); ?></h2>
<p><strong><a href="<?php bloginfo('url'); ?>" alt="<?php bloginfo('name'); ?>">Home</a>**</p>
<h3>All internal pages:</h3>
<ul>
<?php wp_list_pages('title_li='); ?>
</ul>
<h3>All internal blog posts:</h3>
<ul>
<?php $archive_query = new WP_Query('showposts=1000');
while ($archive_query->have_posts()) : $archive_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> <strong><?php comments_number('0', '1', '%'); ?>**</li>
<?php endwhile; ?>
</ul>
<h3>Monthly archive pages:</h3>
<ul>
<?php wp_get_archives('type=monthly'); ?>
</ul>
<h3>Topical archive pages:</h3>
<ul>
<?php wp_list_categories('title_li=0'); ?>
</ul>
<h3>Available RSS Feeds:</h3>
<ul>
<li><a href="<?php bloginfo('rdf_url'); ?>" alt="RDF/RSS 1.0 feed"><acronym title="Resource Description Framework">RDF</acronym>/<acronym title="Really Simple Syndication">RSS</acronym> 1.0 feed</a></li>
<li><a href="<?php bloginfo('rss_url'); ?>" alt="RSS 0.92 feed"><acronym title="Really Simple Syndication">RSS</acronym> 0.92 feed</a></li>
<li><a href="<?php bloginfo('rss2_url'); ?>" alt="RSS 2.0 feed"><acronym title="Really Simple Syndication">RSS</acronym> 2.0 feed</a></li>
<li><a href="<?php bloginfo('atom_url'); ?>" alt="Atom feed">Atom feed</a></li>
</ul>

<div class="clear rule"></div>
  1. Save as sitemap.php and upload it to your theme directory, typically at /wp-content/themes/yourtheme/. In the admin panel, create a new page with any title you like, set the post slug to “sitemap”, select “sitemap” as the template, and publish.

That’s it — your custom sitemap is ready! The URL will be http://www.xxxxx.com/sitemap.
PS: With this method, you can customize the URL as long as the page template is set to sitemap.

4. Using the Chinese Plugin Baidu Sitemap Generator

Download: http://liucheng.name/883/
I personally love this plugin — it’s incredibly simple. My blog uses this very plugin by Liucheng.

I won’t go into detail on the setup — just follow the instructions on the plugin’s page.


So there you have it — four methods for creating a sitemap (well, one is essentially a repeat). Feel free to choose whichever works best for you. Personally, I think using the Google XML Sitemaps plugin to create a Google sitemap, combined with a Baidu sitemap, covers most of your needs. After all, our blogs are primarily for recording life’s little moments, not just for SEO.