30 How to Create a Sitemap with Google Feed Control
Tuesday, September 1, 2009 /



One question I am asked often is how to create a sitemap, where posts are organized by category (label) and link directly to blog posts.



There are several ways this could be achieved, such as manually coding a sitemap, or using a service to generate the feeds for each individual label.



In this article, I'll explain my favourite method for creating a sitemap/table of contents for Blogger blogs: using a modification of Google "Feed Control" to generate a sitemap automatically using the minimal amount of code.







Overview

Creating a sitemap using Google's Feed Control is a relatively simple task. You need not know anything about JavaScript or HTML code in order to use this tutorial: so long as you're able to copy and paste, this should be fairly easy to install!



The sitemap we will create will list all post titles from your blog, organized by their category/label on a post page. We can then link to this post page from elsewhere in the Blogger template, such as a link menu beneath the header, or a link list in the sidebar which details links to other important pages of your site.



Once complete, your sitemap will appear something like this, featuring the title of your label, followed by links to each post filed under this category:










You may also like to take a look at the sitemap I've created for Blogger Buster to see how this works in more detail.






Update - Easy install TOC/Sitemap Script for Blogger by Abu Farhan

Abu Farhan has created a very simple Table of Contents/Sitemap script for Blogger users which can be installed very quickly and easily.



This alternative script uses only two lines of code, and can easily be pasted into a post page (or even a sidebar widget if preferred). All we need to do is change the URL of our blog.



Once installed, this script automatically parses and displays each post under label headings and displays in alphabetical order. What's more, the latest 10 posts from each category are highlighted with "New" so readers can easily notice the most recent posts.



Unlike my Google Feed Control script, this installation is not limited to 100 posts per category.



Be sure to take a look at this excellent script and installation instructions on Abu's site as this is much easier to install and generated a very clean, organized sitemap with little effort.



Thank you for sharing your script, Abu!

How to create your sitemap with Google Feed Control

There are four main steps to creating a dynamic sitemap with Google Feed Control:




  1. Generate an API key from Google


  2. Add the template for your sitemap to a post page

  3. Paste in your API key

  4. Paste in the URLs for your label feeds

Let's look at each step in detail.





Generate your API key

In order to use Google's Feed Control, you'll need to generate a unique API key for your blog.



This key will be unique to your particular blog, and may only be used on the domain you specify during sign-up. If you have multiple blogs and would like to install a sitemap on each blog, you'll need to generate a new API key each time.



Your API key is provided free of charge, and enables you to utilize scripts which are hosted on Google servers (so we don't need to upload and host these scripts elsewhere!).



So, first things first! Generate a Google AJAX API key for your site, and copy this long string to your clipboard (or your favourite text editor) for later use.





Paste the template for your sitemap into a post page

The next step to installing a sitemap is to paste the "template" on which your sitemap will be based into a post page.



Simply go to your Blogger dashboard and create a new post. Using the tabs at the top, switch over to the "Edit HTML" section of the post editor (if you do not usually use this function), then paste the following section of code into the content section:



<style type="text/css">

  /**

   * Suppress everything except for title

   */

  #feedControl .gf-snippet,

  #feedControl .gf-author,

  #feedControl .gf-spacer,

  #feedControl .gf-relativePublishedDate {

    display : none;

  }

</style>

<script type="text/javascript" src="http://www.google.com/jsapi?key=YOUR_API_KEY"></script>

<script type="text/javascript">

    /*

    *  How to use the Feed Control to grab, parse and display feeds.

    */

   

    google.load("feeds", "1");

   

    function OnLoad() {

      // Create a feed control

      var feedControl = new google.feeds.FeedControl();

   

      // Add blogger label feeds.

      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");

      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");

      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");

      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");

      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");

      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");

      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");

      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");

      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");

      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");

     

      feedControl.setNumEntries(-1);

   

      // Draw it.

      feedControl.draw(document.getElementById("content"));

    }

   

    google.setOnLoadCallback(OnLoad);

    </script>

<div id="content">

Loading, please wait...</div>
The <style> section at the head of this code prevents the summary (usually printed by the Feed Control script) being displayed, so that only the linked title is displayed on the sitemap page.



You may notice I've also highlighted other sections in bold coloured text. These are the sections we need to edit for your particular blog, as outlined below.





Paste in your unique API key

In the code you have pasted in your post page, you need to replace "YOUR-API-KEY" with the unique API key you generated at the beginning of this tutorial.



It is easiest to have your API key copied to your clipboard; then highlight YOUR-API-KEY and key CTRL+V (or CMD+V) to paste the key instead of the phrase.





Paste in the URLs and titles for your Label Feed URLS

This step of the tutorial is a little more complex.



We need to paste the URLs of the label feeds we would like to use for the sitemap in place of YOUR-LABEL-FEED-URL, and replace TITLE-OF-YOUR-LABEL with an explanatory title for each relevant line of the Feed Control script.



Each line we need to edit looks like this in the script we have pasted into the post editor:



      feedControl.addFeed("http://URL-OF-YOUR-LABEL-FEED?max-results=100", "TITLE-OF-YOUR-LABEL");
In total, I have used 10 lines (for 10 different labels) in the template script. If you require more, simply duplicate this line and add your label feed urls and titles as appropriate.



Similarly, lines may be deleted if you need to use less than 10 labels for your sitemap.



Your label feed URLs will be something like this:



http://your-blog.blogspot.com/feeds/posts/-/LABEL-NAME

or

http://www.yourblog.com/feeds/posts/-/LABEL-NAME
where LABEL-NAME is the name of the label you are using in your blog.



We also need to include the variable "?max-results=100" at the end of the label feed URL to ensure the maximum 100 posts from each label will be displayed. Otherwise, only the first 25 posts will display in our sitemap.



For example, the URL I use to display all posts filed under the Gadgets label is



http://www.bloggerbuster.com/feeds/posts/-/Gadgets?max-results=100
If any of your labels include spaces, you must replace the spaces with %20 instead.



Here's another example, using my Customize your Blogger Template label:



http://www.bloggerbuster.com/feeds/posts/-/Customize%20your%20Blogger%20Template
Finally, the URLs of your label feeds are case sensitive. If you use any capital letters in the names of your Blogger labels, you will need to match these in the label feed URLS.



The LABEL-NAME element of each line is where you need to type the name/title of the label feed. This aspect is not case sensitive, since it is not generated by your label feeds. If you like, you can use a title which is not the same as the label feed to offer a more explanatory title for your readers.



Here is how I have coded the sitemap for Blogger Buster:



<style type="text/css">

  /**

   * Suppress everything except for title

   */

  #feedControl .gf-snippet,.gf-author,.gf-spacer,.gf-relativePublishedDate {

    display : none;

  }

</style>

<script type="text/javascript" src="http://www.google.com/jsapi?key=MY-API-KEY"></script>

<script type="text/javascript">

    /*

    *  How to use the Feed Control to grab, parse and display feeds.

    */

   

    google.load("feeds", "1");

   

    function OnLoad() {

      // Create a feed control

      var feedControl = new google.feeds.FeedControl();

   

      // Add blogger label feeds.

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Customize%20your%20Blogger%20Template?max-results=100", "Customize your Blogger Template");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Customize%20your%20Blogger%20Template?start-index=101&max-results=100", "Customize your Blogger Template (Part 2)");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Blogger%20News%20and%20Issues?max-results=100", "Blogger News and Issues");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Gadgets?max-results=100", "Gadgets");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Free%20Blogger%20Templates?max-results=100", "Free Blogger Templates");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Resources?max-results=100", "Resources");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Custom%20Domains?max-results=100", "Custom Domains");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Images%20Icons%20and%20Badges?max-results=100", "Images and Icons");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Labels%20Categories%20and%20Tags?max-results=100", "Labels, Categories and Tags");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Monetize%20Your%20Blog?max-results=100", "Monetize Your Blog");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/RSS%20Feeds%20and%20Syndication?max-results=100", "RSS Feeds and Syndication");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/SEO%20and%20Blog%20Traffic?max-results=100", "SEO and Blog Traffic");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Blogger%20Template%20Resources?max-results=100", "Template Resources");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Announcements?max-results=100", "Blogger Buster Announcements");

      feedControl.setNumEntries(-1);

   

      // Draw it.

      feedControl.draw(document.getElementById("content"));

    }

   

    google.setOnLoadCallback(OnLoad);

    </script>

<div id="content">

Loading, please wait...</div>
Once you have finished adding the Label feed URLs and titles to your Sitemap post, you can publish your post and enjoy using your new Blogger sitemap!





Troubleshooting your FeedControl Sitemap

Here are a few issues which you may encounter when installing your sitemap:



The sitemap takes ages to load!

This may happen if you use a large number of labels in your sitemap. Few label feeds will load quickly, while many will take a long time to load.



If this is of particular issue, try to reduce the number of labels/feeds in your sitemap.



The sitemap does not display!

If the sitemap does not load at all, this may be due to an error when pasting the initial template code, your API key or a label feed.



The best advice would be to begin the installation again, making sure you use the Edit HTML mode of your post editor and are careful not to accidentally delete any other elements of the code.



You should also take care not to switch to "Compose" mode while editing your sitemap as this sometimes makes involuntary changes to HTML code which could corrupt the sitemap script.



Certain Labels do not display any posts

This may happen in cases where the URL of your label feed is not quite correct, for example, the title is not capitalized, or spaces are not replaced with %20.



In this case, edit your template and check the URL of the offending label feed carefully for any involuntary errors. Make changes as appropriate, and save your template.



I have more than 100 posts filed under a particular label. How can I display all posts?

Google's Feed Control can only be used to display up to 100 posts from a particular feed. In order to display more results, we need to add a new feed variable, in which the start index is 101.



In the Blogger Buster sitemap, for example, I need to display more than 100 posts for the Customize your Blogger Template category. In the line after the first 100 results for this category, I paste a new line where the start index of the feed is the 101st post, like this:





      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Customize%20your%20Blogger%20Template?max-results=100", "Customize your Blogger Template");

      feedControl.addFeed("http://www.bloggerbuster.com/feeds/posts/default/-/Customize%20your%20Blogger%20Template?start-index=101&max-results=100", "Customize your Blogger Template (Part 2)");
If your label includes more than 200 posts, you can add a third variable where the start index is 201, and so on.





Adding extra content, and styling your sitemap

It is possible to add extra content to your sitemap page, for example, a explanatory paragraph or links to other important pages of your template.



Ideally, you should add this content while editing your sitemap in Edit HTML mode. Be sure to add this content above or below your sitemap script to prevent any errors which would prevent the sitemap displaying properly.



If you would like to style elements of the sitemap, you can achieve this using CSS (either by adding to the <style> section in the Sitemap script, or within the <b:skin> section of your Blogger template.



Here are the classes you can use for styling your sitemap:




  • #feedControl - the ID for the overall sitemap


  • .gf-title - the title of each label

  • .gf-author - the author of each post

  • .gf-relativePublishedDate - the published date displayed beneath each title





Final Thoughts

I hope this tutorial offers a comprehensive guide to using Google's Feed Control to create a dynamic updating sitemap for your Blogger blog! I understand this is not a simple "one click install" sitemap, though as this sitemap updates automatically each time we create a new post, I find this is the easiest, most flexible option to use.



I would love to know of any simpler installations for this sitemap, so if you have written one (or have discovered a tutorial), please feel free to let us know in the comments.



30 comments:

September 1, 2009 at 2:06 PM Ocim said...

i don't understand about this widget but i interesting use this

thanks

September 1, 2009 at 3:40 PM Tutorial SEO said...

Nice info amanda
your experimentation very good

September 1, 2009 at 3:41 PM Iphone BlackBerry said...

looking for BlackBerry Desktop Manager

September 1, 2009 at 4:18 PM Richard said...

I had to remove linebreaks from the code before it would work. My only remaining problem is that the "display: none" styling doesn't seem to work. (See here.)

September 1, 2009 at 6:17 PM Abu Farhan said...

I made Sitemap for blogger too but only use two line script and have categorized by label automatic please visit this link TOC for blogger

September 1, 2009 at 8:57 PM 70dA said...

thanks , i can do it , but tell us the benefits of it for example add it in google webmaster tools or what ?

September 1, 2009 at 9:05 PM Lender said...

The tutorial was very informative. I didn't know that creating a sitemap would be such a complicated process. Thanks you for making it simpler.

September 2, 2009 at 4:50 AM Abu Farhan said...

Thank you very much for link my small blog to your post.I have one more trick for popular post but still in indonesian language maybe later I'll translate Popular post for blogger.

Thanks again, you are the best.

September 2, 2009 at 7:04 AM Raghu (a.k.a Salvatore)™ said...

Can this be added as a HTML/Javascript widget in Blogger?

Cheers

September 2, 2009 at 7:53 AM Blogger User said...

I guess its a good widget or say hack to use for blogger who have less labels or less important categories in their blog.
Anyway Its great. Thanks.

September 2, 2009 at 8:14 AM ProfessionalLab beta 2009 said...

Thanks a lot and thanks to Abu!
It's so easy to use and extremely helpful.

September 2, 2009 at 1:49 PM Dawn Farias said...

What output does the "Submit Feed As Sitemap" function in Google's "Webmaster Tools" give that's different from this tutorial? TIA.

Thanks for the tut.

September 2, 2009 at 8:58 PM Brad Farless said...

Used Abu Farhan's method to get a really great table of contents going. It was super easy to install. Just pasted the two lines of code into an empty post (Edit HTML section), backdated it and then published it and ... that's it. It works.

I have 200+ posts and 16 labels and it doesn't take too terribly long for that page to load.

If you wanna have a look for yourself you can click here.

September 2, 2009 at 11:27 PM Reza Winandar said...

Abu Farhan is a great blogger from Indonesia and me too!And you are a great blogger too! Thanks for tutorial and let me do this!

September 3, 2009 at 2:04 AM
Anonymous said...

To: Raghu (aka Salvatore) Yes. I used the 'Dynamic Feed Control' (Google) within the first sidebar on the item page. See:

http://blog.cidec.ch/2009/08/mitarbeit-in-google-gruppen.html

http://googleajaxsearchapi.blogspot.com/2007/10/ajax-feed-api-addition-dynamic-feed.html

September 3, 2009 at 3:21 AM Peter said...

Hi Amanda! A very big thank you to you and Abu Farhan for this. Loads fast, works great and very professional. A nice touch to my blog! Something I have been looking for, for sometime now!

Take Care,
Peter

September 3, 2009 at 3:49 PM
A GOOG said...

Hello Amanda,

Do you put this sitemap in your dashbord of Google webmaster' s tool?

September 3, 2009 at 5:49 PM
Anonymous said...

Great tutorial: one question - how to make the titel of each category BOLD to make them stand out from the list of posts?

September 3, 2009 at 5:54 PM
Anonymous said...

Me again from last question (sorry, I misspelt the word TITLE): h

How to make thumbnail of first image in post display in this feed? I already use the endgageteer one, but it displays only 25 posts max ...

September 4, 2009 at 6:58 AM My Best Choices said...

Hello Amanda,

Thanks a lot.works very well.
click here.
wait a moment..

September 4, 2009 at 7:34 PM Vineeth said...

Sir....

Can i create a sitemap for blogger blog?

September 6, 2009 at 12:43 PM PseudoRandom said...

Hiya,

This is great! I'm using this in the sidebar to list my previous posts, sorted by label (see Mind Over Matter). I have one question: how do I hide the snippet, author and published date?

September 7, 2009 at 7:39 AM mattandeliz said...

I'm trying Amanda's version because I want a targeted map of just a few of my labels. Several troubleshooting issues:

1)I edited style in my Blogger layout. .gf-title seems to control the format for the title of each post. What's the code to edit style for each LABEL title?

2) I had the same trouble as Richard -- the "supress" coding isn't working. I also tried display:none for author names in my Blogger layout and that didn't work either.

3)There are a lot of blank lines at the beginning of the post that I don't seem to be able to get rid of.

My trial post is here:

http://thenaturalcapital.blogspot.com/2008/12/index-posts-about-animals-on-natural.html

September 7, 2009 at 7:50 AM mattandeliz said...

Update: for some reason display:none works for .gf-snippet but not for .gf-author -- is .gf-author the correct name for the class?

September 7, 2009 at 9:05 AM webdesign said...

Nice Script and thanks for sharing. I got this from a friend via a link in an e-mail

September 7, 2009 at 9:35 AM Remba said...

Walah ga mudeng mba Amanda..!!!

………………….._,,-~’’’¯¯¯’’~-,,
………………..,-‘’ ; ; ;_,,---,,_ ; ;’’-,…………………………….._,,,---,,_
……………….,’ ; ; ;,-‘ , , , , , ‘-, ; ;’-,,,,---~~’’’’’’~--,,,_…..,,-~’’ ; ; ; ;__;’-,
……………….| ; ; ;,’ , , , _,,-~’’ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ¯’’~’-,,_ ,,-~’’ , , ‘, ;’,
……………….’, ; ; ‘-, ,-~’’ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;’’-, , , , , ,’ ; |
…………………’, ; ;,’’ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;’-, , ,-‘ ;,-‘
………………….,’-‘ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;’’-‘ ;,,-‘
………………..,’ ; ; ; ; ; ; ; ; ; ; ; ;__ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ‘-,’
………………,-‘ ; ; ; ; ; ; ; ; ; ;,-‘’¯: : ’’-, ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; _ ; ; ; ; ;’,
……………..,’ ; ; ; ; ; ; ; ; ; ; ;| : : : : : ; ; ; ; ; ; ; ; ; ; ; ; ; ,-‘’¯: ¯’’-, ; ; ;’,
…………….,’ ; ; ; ; ; ; ; ; ; ; ; ‘-,_: : _,-‘ ; ; ; ; ; ; ; ; ; ; ; ; | : : : : : ; ; ; .|
……………,’ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ¯¯ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;’-,,_ : :,-‘ ; ; ;|
…………..,-‘ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ,,-~’’ , , , , ,,,-~~-, , , , _ ; ; ;¯; ; ; ; ; ;|
..…………,-‘ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;,’ , , , , , , ,( : : : : , , , ,’’-, ; ; ; ; ; ; ; ;|
……….,-‘ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;’, , , , , , , , ,’~---~’’ , , , , , ,’ ; ; ; ; ; ; ; ;’,
…….,-‘’ ; _, ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ‘’~-,,,,--~~’’’¯’’’~-,,_ , ,_,-‘ ; ; ; ; ; ; ; ; ; ‘,
….,-‘’-~’’,-‘ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; | ; ; | . . . . . . ,’; ,’’¯ ; ; ; ; ; ; ; ; ; ,_ ; ‘-,
……….,’ ; ;,-, ; ;, ; ; ;, ; ; ; ; ; ; ; ; ; ; ‘, ; ;’, . . . . THAT'S JUST WRONG---‘’’
………,’-~’ ,-‘-~’’ ‘, ,-‘ ‘, ,,- ; ; ; ; ; ; ; ; ‘, ; ; ‘~-,,,-‘’ ; ,’ ; ; ; ; ‘, ;,-‘’ ; ‘, ,-‘,
……….,-‘’ ; ; ; ; ; ‘’ ; ; ;’’ ; ; ; ; ; ; ; ; ; ; ‘’-,,_ ; ; ; _,-‘ ; ; ; ; ; ;’-‘’ ; ; ; ‘’ ; ;’-,
……..,-‘ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;¯¯’’¯ ; ; ; ; ; ; ; ; , ; ; ; ; ; ; ; ; ;’’-,
……,-‘ ; ; ; ; ; ; ; ,, ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; |, ; ; ; ; ; ; ; ; ; ; ‘-,
…..,’ ; ; ; ; ; ; ; ;,’ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;|..’-,_ ; ; ; , ; ; ; ; ; ‘,

September 8, 2009 at 3:50 AM
Klodian said...

Im not sure, if this is recommended to be used on blogger. Blogger do automatically sitemap and not need to submit anything.

September 12, 2009 at 5:49 PM blog-gempaq said...

U miss the "default" in this pharase...

http://your-blog.blogspot.com/feeds/posts/-/LABEL-NAME [u missed the"default"]

please correct it... it's not working...

it should be:
http://your-blog.blogspot.com/feeds/posts/default/-/LABEL-NAME

note: this error under:
Your label feed URLs will be something like this: < in your post.

I think I guess correctly..

http://man-sur.blogspot.com

September 17, 2009 at 1:01 AM t4-trix said...

i use rss and atom feed for google webmaster sitemap

September 19, 2009 at 9:16 AM tedy said...

Thank's for your info

Post a Comment