SharePoint 2013 - Wiki page Table of Contents

I recently completed some rather lengthy documentation within a few SharePoint wiki pages.  It became clear to me that I would need a table of contents, and SharePoint didn't have an out of the box solution specifically for wiki pages. What I wanted was something like a Word document's Navigation pane, which gets generated dynamically based on the document's headings. I also wanted the ability to use this quickly and easily multiple times, without having to utilize SharePoint Designer.

I searched online, and couldn't find exactly what I needed. So, I decided to build my own. I borrowed ideas from two blog posts, a Table of Contents and Build a Webpart example. I wanted my ToC to be in the form of a list. I also wanted the ToC to only have items from the left most content area of the wiki. My thought was the ToC would be on the right sidebar, along with some other content - like a Note Board or something.

Here is the solution I came up with:
  1. Create the following three files.
    • Change 'team-site' to match your site name.
  2. Create a new document library called "XmlWebParts".
  3. In the library, ceate a new folder called "sp-wiki-toc".
  4. Upload the .xml, .js and .css files into this folder.
  5. Find the sp-wiki-toc.xml file in the folder, click on the three dots and copy the url.
    • Save this url, you will need it later.
  6. Navigate to a wiki page needing a Table of Contents.
    • Make sure there are multiple heading on the page.
  7. Edit the page and change the Text Layout to be "One column with sidebar"
  8. Click in the sidebar area and insert Web Part
  9. Under the Content Rollup Category, select XML Viewer.
  10. Open the properties of this new web part and paste the url from step 5 in the XML link field.
  11. Click OK, then Save the page.
  12. Refresh the page and you should see your Table of Contents!
I plan on tweaking this more and more as I use it. I have added this little project to GitHub, take a look!


Popular posts from this blog

String Manipulation in PeopleCode

PeopleSoft Expense Report : Status stuck in "Submission in Progress"

"You are not authorized for this page" error on Worklist link