This TechNet Wiki article shows you how to automatically add a table of contents to your Wiki article by using the "[ TOC ]" tag. You need to include headers in your article, and then the TOC tag places a table of contents that will link down to the corresponding section of your article.


Step 1: Enter Edit Mode

Create a new Wiki document or edit an existing Wiki article.

Click the Edit tab to get into edit mode.


Step 2: Author Your Document 


Step 3: Use the Heading Paragraph Style

Format paragraph headers using the Heading paragraph style (the drop-down box on the top left of the toolbar), such as "Heading 1".


Step 4: Use the [TOC] Script 

Add the code [TOC] (<opening square bracket>TOC<closing square bracket>, without spaces!) in your document, like the sample below.



Step 5: Save the Article


Step 6: See the Magic


Return to Top


Caution: If Any Headers Have Zeros

If any headers have the zero character, "0", you must edit them in the HTML editor. The header text can have zeros, but after the article is saved, you must edit the <a name> tag in the header line to remove or replace all zero characters. If there are any zero characters, the header line will not appear in the Table of Contents.


Caution: If Any Headers Are Duplicates

If any headers are duplicates, you must edit them in the HTML editor. The header text can be duplicated in the article, but the <a name> tags must be unique. Modify the <a name> tags to ensure uniqueness.

To demonstrate the problem with duplicate headers, check the example header lines below in the next section. They are designed to demonstrate the hierarchy of headers in the resulting Table of Contents at the top of this article. However, notice that three of the headers have the text "Sample Header 3". If you test the Table of Contents at the top of this article, you will see that all three of the corresponding entries in the TOC link to the same point in this article. All three headers have the same <a name> tag.


Caution: If any Headers Have Leading Digits

If any headers have leading digits, such as "1" or "2", these will be ignored in the automatically generated <a name> tag when the article is saved. This means that the <a name> tag may not be unique. For example, if your article has the header line "1.2 References", and later the header line "3.1 References", the <a name> tags will not be unique. You must modify the <a name> tags in the HTML to make them unique, so the TOC will work properly. Leading digits in the <a name> tag will be ignored, but digits are allowed anywhere else in the name. For example, you could modify the <a name> tags in the example to be <a name="References_1_2"> and <a name="References_3_1">.

Note: Spaces and periods must be replaced by underscores.

Important Note: If your article's TOC is not showing up as expected, see below to get help and fix your TOC!

Return to Top

Sample Header 1

Sample Header 2

Sample Header 3

Sample Header 3

Sample Header 4

Sample Header 5
Sample Header 6


Return to Top

Hierarchy in the TOC

As you saw in the section above, your headers determine the hierarchy of the TOC (how much they are indented). Your headers automatically build out <a name=example></a> tags into the HTML, and the TOC feature uses those tags along with header number in order to determine the hierarchy in the TOC.

For example, on this article, "Feature Requests for TechNet and MSDN Profiles and Social Platform Tools" (yes, some interesting articles exist on TechNet Wiki), I used Heading 3 headers to create the top sections of each platform tool (such as Wiki, Forums, Blogs, Profiles, and Gallery). Then I used a Heading 2 to make the "Completed/Closed Requests" section at the bottom. Even though it's a higher headings, the H3s were listed first, and so the H2 below them is listed at the same hierarchical level as the H3s (this is a good thing; trust me). Then under my H2 ("Completed/Closed Requests"), I included several H3 sections for each social platform tool. This time, because those H3s were listed below the H2 section, they were indented to the right in the TOC hierarchy:

So it's a fantastic and smart system! And that's one advantage that the TechNet Wiki TOC has over other Wiki TOCs... you control the hierarchy and how many levels you want! This easy to add feature is excellent for users of all skill levels! The TOC will make your WIKI stand out from other WIKI's!


Return to Top

Back to Top Link

There is no automatic way to link back to the top of your article. You can create a new anchor at the top of your article, write text, and then link to the top of your article (and then copy and paste that into the bottom of each section of your article).

A faster way to do that is to copy this text and paste it in one time in your article (at the bottom of a section):

Return to Top

Click anywhere on the link text, click the "Insert Link or Anchor" icon on the toolbar, and update the article name in the "URL" text box (you can get it from your browser's address bar). For example, you'll want to replace "3329" with your article's ID or text name.

Once you modified your "Return to Top" link, copy and paste it anywhere in your article to keep those changes you made.

If you prefer having your link go up to the top text of your article (not the top of the page), then you'll need to create the anchor on your page first (click at the top, click the "Insert Link or Anchor" icon on the toolbar, click the Anchor tab, type "Top" in the Name text box, and click OK), and then change your link to point to that (click anywhere on the link text, click the "Insert Link or Anchor" icon on the toolbar, choose "Top" from the Existing Anchor list box, and then click OK).


Return to Top

Fix your TOC

If you're having trouble to get the TOC right, please check this article:

And if you're still having trouble:


Return to Top

Community Resources


Other Languages

This article is also available in the following languages :

↑ Return to Top