Seo Friendly Table of Contents

This plugin puts a table of contents on your page. You just need to type one line of code in the page/post editor. That’s it! You dont need to edit your themes source code. The plugin allows you to set a title of the toc box. You can also choose which heading tags (h1,h2,h3,h4 etc) you want to have in the table of contents.

Installation

  1. Download the plugin at WordPress.org
  2. Upload the plugin source to the `/wp-content/plugins/` directory
  3. Activate the plugin through the ‘Plugins’ menu in WordPress
  4. Put [toc levels=2 title="Table of contents"] on a page with at least one h2 heading.

Usage

Put [toc levels=2 title="Table of contents"] on a page with at least one h2 heading.

Notes

The plugin assumes that you are using headings correctly. If you use [toc levels=3 title="Table of contents"] then the first heading in the content should be a h2. You must not have a h4 before you use h3. Follow common sense and rules of writing a good texts and you will have no problem.

FAQ

How can I make the table of contents centered, or make it change colors?
If you want to style the table of contents you have to use CSS. The plugin does not write the CSS itself but there might be a future update that will include this feature.

How do I use the function call to get my table of contents?
It is way easier that in version 1 of the plugin. All you have to do is to write these lines in your template:

 //get the table of contents
 $toc=getSeo_toc(array(2,3,4),"Table of contents");
 //print the table
 echo $toc;

Screenhots

<image>

Changelog

2.0.1 (2012-08-27):
Fixed the backwards compatibility break.

2.0.0 (2012-08-26):
Did some major updates to the plugin. Now it is easier to use the php-function to get the table of contents and the shortcode is not visible on the excerpt.
WARNING
: This function is not compatible with previous version of the plugin. If you are updating you have to do some changes in your earlier posts or template files. (Fixed in version 2.0.1)

1.3.7 (2012-05-16):
Added a callback function to import the style.

1.3.6 (2010-11-22):
Removed some minor HTML errors and added a CSS class.

1.3.4 (2010-08-01):
I created it.

  • http://seoyourblog.com chakkravarthi

    I want to display the table of contents to the right end of the post. How can I achieve this? any help with be great .

    BTW This is one of the best plugins I will add it to my collections of best wordpress plugins :)

    Thanks

  • Pingback: Seo firendly table of contents | Tobias Nyholm

  • http://virtualcrowds.org/contents Terence

    It doesn’t work at http://virtualcrowds.org/contents even with [toc="2,3" title="Table of contents"] in the html. Is this because of interference from another plugin perhaps, or maybe it doesn’t like BuddyPress?

  • http://seoyourblog.com chakkravarthi

    How to deactivate it in the homepage but instead use it in posts and pages. ?

  • http://www.tnyholm.se Tobias

    Hi. Thanks for the feedback.
    chakkravarthi:
    If you want to have a Table of contents on every page except for the homepage, I would use the function call in single.php and page.php. With a little help from CSS you can put it every where you want.

    Terence:
    You dont have any content on that page. Put some h2 and h3 heading on it.

  • http://virtualcrowds.org/contents Terence

    OK, that wasn’t clear to me. I thought it was designed to index the site and produce the TOC automagically.

  • http://sellmymobilephone.net David @sellmymobilephone.net

    @Tobias
    Cool plugin, it’ll definitely come in handy on a couple of my websites and save me having to do this all manually. Thanks :D

    @Terence
    You’ve got this plugin confused… I think what you want is a plugin that essentially creates a Sitemap for the entire website and not a TOC for an individual page which is what I believe this plugin does.

    From what I can tell, as Tobias has told you, it only checks the page for h2+ tags and then adds them to the top of the same page. It doesn’t go through all the pages on your website creating a complete TOC like you’d find at the beginning of a book. But I do have a suggestion…

    FYI, I’m not the author of this plugin…
    (dagondesign.com/articles/sitemap-generator-plugin-for-wordpress)
    ”Sitemap Generator Plugin for WordPress” – ”This plugin creates a sitemap for your WordPress powered site. This is not just another XML sitemap plugin, but rather a true sitemap generator which is highly customizable from its own options page in the WordPress admin panel.” This is version 3.17, version 3.15 is on wp.org, but there is an updated version on there by somebody else that says it allows the plugin to work on the homepage. I’m guessing that’s what you want? For the TOC/Sitemap to be on the homepage? If so – wordpress.org/extend/plugins/dagon-design-sitemap-generator-plus.
    I’ve used the original version myself and I reckon it’s probably what you’re after but as for WPMU/MS use, I’ve no idea if it’s possible to have it index an entire website, but it will work on a blog level.

  • mark

    Nice plugin. I want the TOC at the top of certain long posts, but I don’t want it to appear in the auto-excerpt. How do I make it so?

  • http://www.tnyholm.se Tobias

    Thanks Mark.
    That’s a good idea. The plugin does not currently support that feature and I don’t know a good solution to it. I will add it to my TODO list.

  • http://www.malenekirstine.dk Malene Kirstine

    Hi
    First I would like to say that this is a great plugin. Second, I would like to know how and where to change the name of the table of contents so that it is shown in Danish instead?
    Regards, Malene Kirstine

  • http://www.tnyholm.se Tobias

    Hi Malene.
    Thanks.
    You just change the title attr in the shortcode. Try like this:
    [toc="2,3" title="Indholdsfortegnelse"]

  • Igor

    Hi Tobias,
    Thanks for the wonderful and easily customizable plugin!

  • Pingback: Wordpress: Automatisches Erstellen eines Inhaltsverzeichnisses für Artikel | KenntWas.de - Technische Tips

  • http://blog.wuestkamp.com Kim

    hi! very nice plugin and exactly what i was searching for! but is it possible to define a different width of the TOC for every post? i set it with css to a higher width but i want to do it different for every post!

    thanks a lot :)

    kim

  • http://www.tnyholm.se Tobias

    @Igor
    I appreciate your comment. Thanks.

    @Kim
    I can add a css-class to the #toc div. The class will be named ”post-XXX” where the Xes is the id.

  • zeshan

    how to work on multiple pages i.e. when you have in the post.
    also how to change the layout like color or position

  • juan escobar

    The plugin is generating invalid code on my theme, please take a look at http://blogtafolio.co.cc/beta-arq/2010/11/13/tabla-de-contenido-para-articulo-plugin/
    The only weird thing i´ve done is removing some of the css code that came with the plugin (not the entire file) and putting my own css code on a seperate file called from my header.php.

  • http://www.tnyholm.se Tobias

    What do you mean with ”invalid code”? I don’t see any…

  • juan escobar
  • juan escobar

    Oh, btw, any chance to add links in each section of the article to go to the top of the page?

  • http://www.tnyholm.se Tobias

    @juan escobar: I still can’t see anything wrong with the page you are linking.

    It is a good idea. I might implement that in the next update.

  • juan escobar
  • http://www.tnyholm.se Tobias

    Hehe, thanks. I didn’t know you was referring to the HTML. You are correct, I will fix this within the next update

  • juan escobar

    Glad to be of help! Sorry if i sounded too harsch! :D

  • juan escobar

    Tobias, one question: is it possible to override the style of the plugin´s css without neediong to edit it?

  • http://www.tnyholm.se Tobias

    Sure you can. Just put some extra CSS tags in your own css. Like:
    #content #toc_title{
    color:green;
    }
    To make the color of the title green. Don’t forget to use a extra # like content.

  • http://www.spybubblereviewscam.com SPY

    Hey, great plugin! keep up the good work. i’m going to use it on my new site.

  • Danie

    Great plugin and the only one (as a newbie) that I could get to work easily! Is there any way of centering the TOC though?

  • http://freevocabtest.com/ ahmad

    i like it to be inline to the left of a text, I mean inside or beside the text
    or I want it be wider

  • http://www.tnyholm.se Tobias

    Danie and ahmad: You have to use CSS to style the table of content.
    The plugin cant write the CSS itself. It might be a future update though.

  • Phil

    Great plugin.

    @ Danie and ahmad: I managed to move the toc location on the post by surrounding it in a div tag and floating right. This also allowed post text to wrap around the toc. See: http://philowen.info/wiki/test-page-for-wiki-functionality/

  • Slade

    Hi, great plugin!

    Can i create ”back to top” link automatically in every chapter? How?

  • Bloody

    Tobias,

    I want to display the TOC on my single sidebar. I put this code in the sidebar.php :

    ', ']]>', $the_content);
    //print the variables
    echo $toc;
    echo $the_content;
    }
    ; ?>

    But it’s wrong because I got an ” Fatal error: Call to undefined function getSeo_toc() ”

    What is wrong in my code ?
    Thanks for your answer

  • Pingback: 5 more tips for Search Engine Optimization | Creative Ramblings - A Blog by Cendrine Marrouat

  • http://alamoxie.com Alamoxie

    I’m no expert, so I may have this incorrect… but it looks like your plugin is not using the standard shortcode API? http://codex.wordpress.org/Shortcode_API

    My suggestion would be to use the standard shortcode API so that the shortcode could be written:
    [toc headings="2,3,4" title="Table of Contents"]
    …but to have defaults so just the shortcode [toc] should be used. A settings page to edit the defaults would be nice, but if they’re easy to find and change in the plugin PHP file that would work too.

    Instead of specifying headings, it would be great if it would just automatically generate the TOC for any headings that appear after the TOC’s location, ignoring the ones before.

    If the shortcode could be entered inside an HTML comment, that would be great. A problem I have with TOC shortcodes is that if the plugin is disabled or I switch plugins, then suddenly my viewers are seeing unused shortcodes scattered across web pages, and they have to be manually removed.

    Speaking of which, it would be awesome to have it automatically generated on posts or pages… more advanced settings specifying which types of posts and pages would be awesome, but I realize that’s beyond the scope of your plugin. However, reading through the comments it does look like you’ve alluded to a way to have it automatically generated on posts or pages… could you possibly create a tutorial showing step by step how to do that?

    Just some suggestions for your consideration! Thanks!

  • http://alamoxie.com Alamoxie

    Oh–a comment for the person who asked about how to prevent the TOC from appearing in the excerpts. That is a GREAT question, and I wish I had a great answer. I don’t, but here are the options I see:
    1. Manually set an excerpt for every page or post that has a TOC. (But that could be a hassle).
    2. Enter the TOC lower down in the page, then use CSS to make it appear at the top (but that’s poor web design practice).
    3. Find a plugin that allows you more control over how excerpts are generated (any suggestions? I have none).
    4. Use the Wikipedia approach… have the sort of ”executive summary” as a paragraph or two at the top, then the TOC, then all the detailed information broken into sections, each with their own headings. This would be my recommendation.

  • http://kenntwas.de KW

    Hi,

    I have 2 little patches for this nice plugin.
    1. Only generate toc in single or feed articles and not in the main page or category or tag-listings.
    (this is only usefull, if you display the first n chars in your frontpage)

    2. Use absolute URLs in feeds.

    http://kenntwas.de/2011/tips/tools-allgemein/2-patches-for-seo-friendly-table-of-contents-wordpress-plugin/

  • Pingback: Seo Friendly Table of Contents review, discussions, does it work, and ratings on Loadwp.com | Loadwp.com

  • Berg

    Hi,
    How do I get the table of content to float to the right with text wrapped around it?
    Thanks for a nice plugin

  • http://www.tnyholm.se/ Tobias Nyholm

    Write ”float:right;” in your CSS for the #toc-element

  • Berg

    Worked fine when I put it under the #toc. Thanks for the quick reply

  • Terry

    I tried this plug in and two things:
    1. There is no settings option.
    2. It only creates a table for tags above it in the page.  I have pages of posts that are dynamically put on the page, as usual, and I want the table at the top of the page. How do I get it there yet have it ”see” the posts below it?

  • http://www.tnyholm.se/ Tobias Nyholm

     Hey.
    I didn’t think the plugin needed a settings page. I want to keep things simple.
    The plugin checks what you’ve written as content of the page in the admin system. If you have written a script that creates content for you, outside the scope of wordpress, I’m afraid that it is also outside the scope of this and any other plugin.

  • Terry

    It’s the twentyeleven theme page.php:

    get_header(); ?>

    This is a problem? Any ideas?

  • Pingback: Create your own social profile aggregator | Creative Ramblings - A Blog by Cendrine Marrouat

  • Real3

    Hi,
    I badly speak on English (with the help)

    The plug-in doesn’t work with the Russian text. References turn out in a look:
    Как себя подбодрить.
    Тест самоуверенности.
    Подбадривание других.
    Унижение других.
    Жизнь — шутка?
    Боязнь ошибок.
    Сокрытие ошибок.

    All this as a result works incorrectly. Please, prompt as to correct, or let out updating ;)
    The idea of a plug-in is very good, Thanks.
     

  • Lorraine

    How can I get the text to wrap around the TOC. I am using thesis theme and when I go to the TOC plugin css it says it is inactive.  I also dont know where the toc-element is.  Can you please help (sorry for the basic questions but I am new to all of this :) )

  • http://www.tnyholm.se/ Tobias Nyholm

     That is because it only supports UTF-8 characters. Please refer to line 115 and make your changes there.

  • http://www.tnyholm.se/ Tobias Nyholm

     In your CSS file. Write #toc{float:left} then you’ll get the text to wrap around.

  • Dieter Neuvians

    Since your last update (1.3.7) all ToC Headings are not longer than about 40 characters, then go to the next line. This does not look nice in a long list with several sub-Headings. There is also a yellow background colour (see attached image).

    Thanks and best regards,
    Dieter Neuvians

  • Pingback: 25 WordPress plugins worth using | Creative Ramblings

  • Lorraine

    Can you also tell me if it is possible to get the full toc to show on a two page post (allowing the reader to click to the second page) as it only seems to pick up the h2 tags on the first page.
    Many thanks
    Lorraine

  • Halile

    Hi there! How can I make the table of content to be left, beside my text? Thanks for your help

  • Don

    You need to use the add_shortcode function of WordPress. Doing it this way is wrong. If someoe needs to strip shortcodes from an excerpt, etc… then they can’t without parsing your fake shortcode out.

  • http://www.tnyholm.se/ Tobias Nyholm

    You’re right. It was over two year ago I wrote this plugin. I’ve made some changes and updated the plugin to version 2.0.0. But that breaks backwards compatibility.

  • Hady

    Unfortunately, I updated the pluging without reading the changelog. The new version is not working since I am using the old shortcode. I have more than 500 posts published and It’s impossible for me to update all these posts. Is there any way to get back to the old version of the pluging ? Or there is any way to replace the new code with the old one ?
    Thanks!

  • http://www.tnyholm.se/ Tobias Nyholm

    Yes you are right it was stupid. I added an admin menu in version 2.0.1. You can now rewrite your posts automatically.

  • Julian

    Is there a way to add two fixed links to the generated TOC?
    For every article, I always want to have links to the article beginning (which is the h2-tag) and the comments section of that article. That would be very helpful! Thanks!

  • Rene

    Very nice. But the links are not working correctly on my site. The script does not catch the current page URL, but the absolute Path of the Theme or something. How can i work around that without hacking the Plugin?

  • Hady

    Hello,

    I upgraded the pluging to the new version. The shortcode is not working properly after updating it. I’m using h1 and h2 for the main title of my posts and h3, h4, h5 for my subtitles. I insert, for example, [toc levels=5,6 title="Sommaire"] but the plugin is doing links to h1 till h6… How to fix this?
    Thanks,