Wiki: How to Automatically Add a Table of Contents (TOC) to Your TechNet Wiki Article

Wiki: How to Automatically Add a Table of Contents (TOC) to Your TechNet Wiki Article

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.


Steps

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


Important

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:

http://social.technet.microsoft.com/wiki/contents/articles/feature-requests-for-technet-and-msdn-profiles-and-social-platform-tools.aspx

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).

Example:

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 
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Great article, Peter!  Very much needed!

  • That's one of my favorite features in Word for documentation.  Glad to see it made its way to TechNet Wiki!

  • very cool.  What is the easiest way to create jumps back to the TOC so they can navigate back and foth from the TOC to a specific section in the article, rinse, repeat?

  • @Craig,

    Okay I added a "Back to Top Link" section about the fastest manual process for that.  

  • Very useful! I'll keep it in mind.

  • As you know, we're going to localize TechNet Wiki.

    I was thinking about a small problem in the translation system: the "Table of Contents" header will not be translated automatically, but it will always be displayed in English language.

  • I can't get the toc to work correctly in this article:

    social.technet.microsoft.com/.../1011.active-directory-federation-services-ad-fs-overview.aspx

    Three headers are missing from the toc: "What is AD FS 2.0?", "Install AD FS 2.0", and "Manage AD FS 2.0".

  • If not all headers show up in the TOC, then carefully check your HTML code. The most likely cause of missing TOC items is a mismatch in HTML tags

  • Yes, it would be good to have a language flag for this parameter ([toc:hu-HU], [toc:pt-BR] etc.), or a display-text property.