good strategy for markdown layout for "table of contents" (toc) output?

Viewed 231

I'm working on my first README.md file. Seems like I'm seeing a general recommended pattern online to have a top-level "Name" section wrapped with (#) formatting, followed by a "Description" section wrapped with (#). That looks fine to me but looks like some sites like github auto-generate a TOC based on the structure of the md. So an md structure like this:

#Level1
##Level2
###Level3

Would be auto-generated and output like this:

- [Level1]
  * [Level2]
    + [Level3]

So a structure like this:

#Name
#Description
##Section1
##Section2

Would get output like this:

- [Name]
- [Description]
  * [Section1]
  * [Section2]

A quality TOC should only have a single top-level item, so the recommended structure that I'm seeing online wouldn't auto-convert well by default. I googled "markdown exclude from toc" and one reference mentioned including the following comment above the header:

<!-- omit in toc -->

But that approach didn't work for me in an online converter, and not sure how universally that approach is supported. Can you recommend a solution for this? Either I need to restructure that top level, or I need to know a special tag or wrapper which will exclude that particular section from an auto-generated toc

0 Answers
Related