{"id":43142,"date":"2018-03-09T21:01:47","date_gmt":"2018-03-09T13:01:47","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=43142"},"modified":"2018-03-09T18:23:35","modified_gmt":"2018-03-09T10:23:35","slug":"tocbot-table-of-contents","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/","title":{"rendered":"Auto-Generate Table of Contents Using Tocbot"},"content":{"rendered":"<p>Lengthier content is becoming the norm with a stronger reception <a href=\"https:\/\/searchengineland.com\/seo-user-science-behind-long-form-content-230721\" target=\"_blank\" rel=\"nofollow\">from Google<\/a> and as well as the users. But it can <strong>get a bit tiring to read the long-form content<\/strong> with tons of sub-headings to browse.<\/p>\n<p>Enter <a href=\"https:\/\/tscanlin.github.io\/tocbot\/\" target=\"_blank\">Tocbot<\/a>, a free <strong>table of contents generator built on JavaScript<\/strong>. This automatically creates a fixed ToC list on any page and updates your position as you scroll past each heading.<\/p>\n<p class=\"note\"><strong>Read Also:<\/strong> <a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/create-auto-generated-table-of-contents-html-slot\/\">Create Auto-generated Table of Contents with HTML Slots<\/a><\/p>\n<figure><a href=\"https:\/\/tscanlin.github.io\/tocbot\/\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/tocbot-table-of-contents\/01-tocbot-script-homepage.jpg\" alt=\"tocbot homepage\" width=\"1020\" height=\"886\"><\/a><\/figure>\n<p>The <a href=\"https:\/\/tscanlin.github.io\/tocbot\/\" target=\"_blank\">main page<\/a> includes a full preview along with documentation you can follow to get this all setup.<\/p>\n<p>Tocbot has <strong>no dependencies and should run in any browser<\/strong> with JavaScript enabled. You just include the Tocbot JS\/CSS files and let \u2019em run. Simple!<\/p>\n<p>You can even use the <a href=\"https:\/\/cdnjs.com\/libraries\/tocbot\" target=\"_blank\">CDN versions<\/a> if you don\u2019t want to download anything locally. It\u2019s a pretty <strong>simple setup and you can even customize the table of contents<\/strong> to suit your needs.<\/p>\n<p>However this does require a bit of JavaScript to get it working. Specifically you need to run an <strong>init()<\/strong> function with parameters definING where your navigation should appear and which heading(s) you want to target(ie. H1-H6).<\/p>\n<p>Take a look at the <a href=\"https:\/\/github.com\/tscanlin\/tocbot\" target=\"_blank\">GitHub repo<\/a> for more setup info. This includes <strong>browser support, all custom parameters, and the setup instructions<\/strong> for the main JS\/CSS files.<\/p>\n<p>The API comes with <strong>a lot<\/strong> of features you can edit too:<\/p>\n<ul>\n<li>Collapsible list of items.<\/li>\n<li>Sub-headings in table.<\/li>\n<li>Offset for table navigation.<\/li>\n<li>Fixed nav or static.<\/li>\n<li>Extra links to add into the navigation.<\/li>\n<\/ul>\n<p>Some designers may prefer to create their own table of contents from scratch. But that is a fairly technical process and requires plenty of manual effort.<\/p>\n<p>With <strong>Tocbot you\u2019re just one JS function away from a working ToC<\/strong> that runs dynamically across all your page headings.<\/p>\n<p>To learn more visit the <a href=\"https:\/\/tscanlin.github.io\/tocbot\/\" target=\"_blank\">Tocbot homepage<\/a>. This has all the setup info you need along with download links to the CDN(and local) versions of all the Tocbot files.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/tocbot-table-of-contents\/02-tocbot-example-table-of-contents.jpg\" alt=\"tocbot example page\" width=\"730\" height=\"382\"><\/figure>","protected":false},"excerpt":{"rendered":"<p>Lengthier content is becoming the norm with a stronger reception from Google and as well as the users. But it can get a bit tiring to read the long-form content with tons of sub-headings to browse. Enter Tocbot, a free table of contents generator built on JavaScript. This automatically creates a fixed ToC list on&hellip;<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[3393],"tags":[],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Auto-Generate Table of Contents Using Tocbot - Hongkiat<\/title>\n<meta name=\"description\" content=\"Lengthier content is becoming the norm with a stronger reception from Google and as well as the users. But it can get a bit tiring to read the long-form\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Auto-Generate Table of Contents Using Tocbot\" \/>\n<meta property=\"og:description\" content=\"Lengthier content is becoming the norm with a stronger reception from Google and as well as the users. But it can get a bit tiring to read the long-form\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-09T13:01:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/tocbot-table-of-contents\/01-tocbot-script-homepage.jpg\" \/>\n<meta name=\"author\" content=\"Jake Rocheleau\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jake Rocheleau\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/\"},\"author\":{\"name\":\"Jake Rocheleau\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\"},\"headline\":\"Auto-Generate Table of Contents Using Tocbot\",\"datePublished\":\"2018-03-09T13:01:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/\"},\"wordCount\":340,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/tocbot-table-of-contents\\\/01-tocbot-script-homepage.jpg\",\"articleSection\":[\"Toolkit\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/\",\"name\":\"Auto-Generate Table of Contents Using Tocbot - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/tocbot-table-of-contents\\\/01-tocbot-script-homepage.jpg\",\"datePublished\":\"2018-03-09T13:01:47+00:00\",\"description\":\"Lengthier content is becoming the norm with a stronger reception from Google and as well as the users. But it can get a bit tiring to read the long-form\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/tocbot-table-of-contents\\\/01-tocbot-script-homepage.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/tocbot-table-of-contents\\\/01-tocbot-script-homepage.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/tocbot-table-of-contents\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Auto-Generate Table of Contents Using Tocbot\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\",\"name\":\"Jake Rocheleau\",\"description\":\"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/jake\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Auto-Generate Table of Contents Using Tocbot - Hongkiat","description":"Lengthier content is becoming the norm with a stronger reception from Google and as well as the users. But it can get a bit tiring to read the long-form","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/","og_locale":"en_US","og_type":"article","og_title":"Auto-Generate Table of Contents Using Tocbot","og_description":"Lengthier content is becoming the norm with a stronger reception from Google and as well as the users. But it can get a bit tiring to read the long-form","og_url":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2018-03-09T13:01:47+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/tocbot-table-of-contents\/01-tocbot-script-homepage.jpg","type":"","width":"","height":""}],"author":"Jake Rocheleau","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Jake Rocheleau","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/"},"author":{"name":"Jake Rocheleau","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a"},"headline":"Auto-Generate Table of Contents Using Tocbot","datePublished":"2018-03-09T13:01:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/"},"wordCount":340,"commentCount":0,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/tocbot-table-of-contents\/01-tocbot-script-homepage.jpg","articleSection":["Toolkit"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/","url":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/","name":"Auto-Generate Table of Contents Using Tocbot - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/tocbot-table-of-contents\/01-tocbot-script-homepage.jpg","datePublished":"2018-03-09T13:01:47+00:00","description":"Lengthier content is becoming the norm with a stronger reception from Google and as well as the users. But it can get a bit tiring to read the long-form","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/tocbot-table-of-contents\/01-tocbot-script-homepage.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/tocbot-table-of-contents\/01-tocbot-script-homepage.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/tocbot-table-of-contents\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Auto-Generate Table of Contents Using Tocbot"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a","name":"Jake Rocheleau","description":"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers","sameAs":["https:\/\/www.hongkiat.com"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/jake\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-bdQ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/43142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=43142"}],"version-history":[{"count":1,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/43142\/revisions"}],"predecessor-version":[{"id":43143,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/43142\/revisions\/43143"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=43142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=43142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=43142"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=43142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}