To hide the 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.
Recommended: To hide the table of contents on specific content, use the metafield table_of_contents.hidden.
The table of contents is not displayed on content where the table_of_contents.hidden metafield value is 1.
Create the following definition for each content type you want to hide.
Field | Value |
|---|---|
Name | Any name (for example, Hide table of contents) |
Namespace and key | table_of_contents.hidden |
Type | Integer |
Value | 1 hides the table of contents |
(1) Open custom data
Open Shopify admin → Settings → Custom data.
(2) Add a definition
Select blog posts, products, pages, or collections, then select "Add definition."
(3) Enter the definition and save
Enter table_of_contents.hidden as the namespace and key, set the type to 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
Enter 1 in the table_of_contents.hidden metafield, then select "Save."
Prerequisite: Display on products, pages, and collections is available on the Regular plan. You can still create the hide metafield on any 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 the template that should display it.
(1) Split the templates
In the theme editor, open the target template, then split it into one that displays the table of contents and one that does not.
(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 the template to content
From Shopify admin, open the target blog post or page, choose the template, then select "Save."
Note: If a vintage app embed is on, the table of contents can still appear on templates that do not have the app block. On Online Store 2.0, turn the app embed off.