To hide a table of contents created with RuffRuff Table of Contents on a specific blog post, product, page, or collection, use the metafield table_of_contents.hidden. When the value is 1, the table of contents is not displayed on that content. We recommend this metafield method to hide the table of contents on individual content.
Create a metafield definition for each content type (blog posts, products, pages, or collections) where you want to hide the table of contents.
Displaying the table of contents on products, pages, and collections requires the Regular Plan. The hide metafield itself can be set on any plan.
Create the following definition for each content type where you want to hide the table of contents.
Field | Value |
|---|---|
Name | Any name (for example, Hide table of contents) |
Namespace and key |
|
Type | Integer |
(1) Open Metafields and metaobjects
Open Shopify admin → Settings → Metafields and metaobjects (formerly "Custom data").
(2) Open the definitions for the content type
Select blog posts, products, pages, or collections. Selecting blog posts opens the "Blog post metafield definitions" screen.
(3) Enter the definition and save
Select "Add definition." On the "Add blog post metafield definition" screen, enter a name (for example, Hide table of contents), the namespace and key table_of_contents.hidden, and the type "Integer," then select "Save."
(1) Open the content
From Shopify admin, open the blog post, product, page, or collection where you do not want the table of contents.
(2) Set the value to 1
In the "Metafields" section of the edit screen, the name you gave the definition (for example, Hide table of contents) appears. Enter 1 as the value, then select "Save."
After saving, open the configured blog post, product, page, or collection on your online store and check that the table of contents is not displayed.
If the value is anything other than 1, this metafield does not hide the table of contents. Displaying the table of contents still requires the app to be enabled and added to the theme, the selected headings to be present, and the appropriate plan.
On an Online Store 2.0 theme, you can also prepare a template that displays the table of contents and a template that does not. Add the Table of Contents app block only to templates where you want it to appear.
(1) Create separate templates
Open the target template in the theme editor, then create separate templates for displaying and hiding the table of contents.
(2) Add the app block
Add the "Table of Contents" app block only to the template that should display it, then select "Save."
(3) Assign a template to the content
From Shopify admin, open the target blog post or page, choose the template to use, then select "Save."
Check that the table of contents is hidden on posts assigned the template without a table of contents and displayed on posts assigned the template with one.
Note: If a vintage-theme app embed is enabled, the table of contents may appear even on templates without an app block. On an Online Store 2.0 theme, disable the app embed.