githubEdit

Article table of contents


Create metafield definition

  1. Navigate to Settings > Custom data > Blog posts

  2. Click Add definition

  3. In the name field type "Table of contents"

  4. Ensure the namespace and key field is custom.table_of_contents

  5. Click Select type and select "Single line text"

  6. Select List of values

  7. Click save

arrow-up-right

Update metafield values

  1. Navigate to the blog post you'd like to update

  2. Scroll to the bottom and click Show all next to metafields

    arrow-up-right

  3. Enter in values for each heading you want to appear in your table of contents

    arrow-up-right

Add block

  1. In the Shopify theme editor navigate to the blog post template

  2. Click Add block under Article main

  3. Search and select "Table of contents"

arrow-up-right

Update headings

  1. In Shopify navigate to the blog post you'd like to update

  2. Click the "Show HTML" icon on your blog content

  3. Add id="HEADING-NAME" to your heading tags

    1. The id attribute should match the table of contents

    2. For example, you click a table of contents link you'll notice the URL bar is updated - this will give you the value that is needed for your id attribute

    3. The heading tags should now look like this

      arrow-up-right

Last updated

Was this helpful?