Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8928867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:32:45+00:00 2026-06-15T08:32:45+00:00

I have built a website based on the Jekyll code for the website for

  • 0

I have built a website based on the Jekyll code for the website for Apache Buildr. The Buildr website automatically generates a table of contents for each page based on the headers in the textile format files.

For example, you write a page using textile marking out the headings like so . .

h2(#why).  Why are we doing this?

BLah blah balh etc ..


h2(#something). Some other header

BLah blah balh etc ..

Then in the default HTML you have some code that pipes the content into something called toc and then you put the contents afterward. For example …

<div id='content'>
 <h1 id='{{ page.title | downcase | replace(' ', '_') }}'>{{ page.title }}</h1>
  {{ content | toc }}
  {{ content }}
</div>

On the Apache site they get the desired results (the toc is shown followed by the contents). However, on my site, the contents are rendered twice. No table of contents is generated.

Furthermore, if I clone the Apache Buildr project directly from github and run jekyll --server in the doc folder of that project, then no table of contents is generated either.

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:32:46+00:00Added an answer on June 15, 2026 at 8:32 am

    I emailed the Buildr developer mailing list and someone told me to look here for inspiration. Turns out that the relevant code snippet is …

    module TocFilter
      def toc(input)
        output = "<ol class=\"toc\">"
        input.scan(/<(h2)(?:>|\s+(.*?)>)([^<]*)<\/\1\s*>/mi).each do |entry|
          id = (entry[1][/^id=(['"])(.*)\1$/, 2] rescue nil)
          title = entry[2].gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m, '\2').strip
          if id
            output << %{<li><a href="##{id}">#{title}</a></li>}
          else
            output << %{<li>#{title}</li>}
          end
        end
        output << '</ol>'
        output
      end
    end
    Liquid::Template.register_filter(TocFilter)
    

    Make a folder in the source folder of your site called _plugins and then paste this code into a file called TocFilter.rb within that folder.

    It works!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website based on Wordpress, built with pages. I need to have:
I have built a website based on Google App Engine. It includes ten models,
I am using WebMatrix and have built a website based on the StarterSite. In
I have built a website and when my users load up http://info.salemgolfclub.org/Account/Logon the username
I have built a website and now the customer wants to split it between
I am new to the web development.I have built my website in visual studio
I have built a MVC website on IIS6. I used the built-in ASP.NET Security
I have a website built with ASP.NET (3.5) and want add some level of
I have a website built mostly in flash. The flash movie is on an
I have a website built in mvc3. I want to have an image of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.