Shorts Codes

Table Of Content:

Step:1

Paste this code above the closing tag    ]]></b:skin>   or   ]]></b:template-skin>  in your website's main template file (often named style.css or similar). This ensures the styles are applied globally to all pages.

 /* TOC */

.table-of-contents{flex:auto;width:fit-content;background:#eee;font-size:14px;padding:11px;margin:8px 0 30px 0}

.table-of-contents li{margin:0 0 0.25em 0}

.table-of-contents a{color:#2a5365}

.table-of-contents h3{margin:0;cursor:pointer}

Step:2

Paste this code right before the closing </body> tag of your website's main template file. This ensures the script runs after the page content has loaded.

 <script async='async'>

var head,newLine,el,title,link,ToC=&quot;<nav class='table-of-contents' role='navigation'><h3 onclick='toc()'>&#10145;&#65039;Table of Contents</h3><ul style='display:none'>&quot;;$(&quot;article h2, article h2, article h3, article h5&quot;).attr(&quot;id&quot;,function(arr){return &quot;point&quot; + arr;});$(&quot;article h2, article h2, article h3, article h5&quot;).each(function(){el=$(this),title=el.text(),link=&quot;#&quot;+el.attr(&quot;id&quot;),ToC+=newLine=&quot;<li><a href='&quot;+link+&quot;'>&quot;+title+&quot;</a></li>&quot;}),ToC+=&quot;</ul></nav>&quot;,$(&quot;.toc-pro&quot;).prepend(ToC);function toc() {$(&quot;.table-of-contents ul&quot;).toggle();}</script>

Step:3

Within each individual blog post, paste this code where you want the TOC to appear. This could be at the beginning or somewhere else that makes sense for your layout.

<div class='toc-pro'></div>

Post a Comment