WordPressプラグイン「Table of Contents Plus」を使用して目次を作成し、cssでカスタマイズしました。
目次
Table of Contents Plus
コレです。
他にもいろいろあるみたいですが、調べているとコレを利用している人が多かったので参考にさせていただきました。
cssを調整
以下のコードを追加cssに追記します。
/* TOC+ */ #toc_container { display: block !important; width: 95% !important; background: #fff; border: 1px solid #0f4471; font-size: 95%; box-sizing: border-box; line-height: 1.4; margin: 2.5em auto 2.5em; padding: 1em 1em; } #toc_container .toc_title { text-align: center; padding: 0.4em 0; } #toc_container ul { list-style: none; margin-bottom: 0; } #toc_container ul li { margin: 0; padding-left: 0; text-indent: 0; } #toc_container ul a { display: block; text-decoration: none; font-weight:normal !important; font-style:normal !important; color: #444; } #toc_container .toc_list > li > a { font-size: 108%; } #toc_container ul ul { padding: 0.2em 1em 0.2em 0.2em; }
完成図
こんな感じになりました。
開いている状態

閉じている状態

このページの目次ですが、項目が少なすぎてわかりにくいので「hタグ」を並べたページの目次を貼っておきます。

このページです。
階層ごとに頭出しの余白や文字サイズにメリハリをつけています。
階層がわかりやすいように番号もついていますが、コレは無くしてもいいかも。(設定画面でチェックを外せば簡単に消せます。)
「目次」や「表示」、「非表示」等の文言はプラグイン設定ページより簡単に変更できます。

まとめ
簡単に目次作成ができました。
コレで見出しをもっと上手に活用し、まとまりのある文章+SEO的に優秀な記事を目指せます、、、、、