{"id":4980,"date":"2024-10-24T13:45:54","date_gmt":"2024-10-24T13:45:54","guid":{"rendered":"https:\/\/howtogeek.blog\/ja\/?p=4980"},"modified":"2024-10-24T13:45:54","modified_gmt":"2024-10-24T13:45:54","slug":"adding-a-table-of-contents-toc-to-your-ghost-theme-a-stepbystep-guide","status":"publish","type":"post","link":"https:\/\/howtogeek.blog\/ja\/adding-a-table-of-contents-toc-to-your-ghost-theme-a-stepbystep-guide\/","title":{"rendered":"Ghost \u30c6\u30fc\u30de\u306b\u76ee\u6b21 (TOC) \u3092\u8ffd\u52a0\u3059\u308b: \u30b9\u30c6\u30c3\u30d7\u30d0\u30a4\u30b9\u30c6\u30c3\u30d7 \u30ac\u30a4\u30c9"},"content":{"rendered":"<p>Ghost \u30d6\u30ed\u30b0\u306b\u76ee\u6b21 (TOC) \u3092\u7d44\u307f\u8fbc\u3080\u3068\u3001\u9577\u3044\u8a18\u4e8b\u3092\u30b7\u30fc\u30e0\u30ec\u30b9\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3067\u304d\u308b\u305f\u3081\u3001\u8aad\u8005\u306e\u30a8\u30af\u30b9\u30da\u30ea\u30a8\u30f3\u30b9\u304c\u5927\u5e45\u306b\u5411\u4e0a\u3057\u307e\u3059\u3002\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001\u6295\u7a3f\u5185\u306e\u898b\u51fa\u3057\u304b\u3089 TOC \u3092\u81ea\u52d5\u7684\u306b\u751f\u6210\u3059\u308b JavaScript \u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u3042\u308b TOCBOT \u3092\u4f7f\u7528\u3057\u3066\u3001\u4efb\u610f\u306e Ghost \u30c6\u30fc\u30de\u306b TOC \u3092\u8ffd\u52a0\u3059\u308b\u624b\u9806\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<h2 id=\"setting-up-tocbot-in-ghost\">TOCBOT \u3092 Ghost \u306b\u7d71\u5408\u3059\u308b<\/h2>\n<p>TOCBOT \u306f\u3001\u6295\u7a3f\u306e\u898b\u51fa\u3057\u304b\u3089\u52b9\u7387\u7684\u306b\u76ee\u6b21\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u7c21\u5358\u306a\u624b\u9806\u306b\u5f93\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li>Ghost \u7ba1\u7406\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u3001 \u306b\u79fb\u52d5\u3057\u307e\u3059<code>Settings &gt; Code injection<\/code>\u3002<\/li>\n<li>\u3053\u306e<code>Site Header<\/code>\u9818\u57df\u306b\u3001\u5fc5\u8981\u306a TOCBOT \u30b9\u30af\u30ea\u30d7\u30c8\u3068\u30b9\u30bf\u30a4\u30eb\u30b7\u30fc\u30c8\u3092\u633f\u5165\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<p> <code> <code>&lt;script type=\"text\/javascript\"src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/tocbot\/4.21.0\/tocbot.min.js\"&gt;&lt;\/script&gt;<br \/>\n&lt;link href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/tocbot\/4.21.0\/tocbot.css\"rel=\"stylesheet\"&gt;<\/code><\/code><\/p>\n<ul>\n<li>\u6b21\u306b\u3001<code>Site Footer<\/code>\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u3001\u6b21\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f7f\u7528\u3057\u3066 TOCBOT \u3092\u521d\u671f\u5316\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<p> <code> <code>&lt;script&gt;<br \/>\n  document.addEventListener('DOMContentLoaded', function() {<br \/>\n    tocbot.init({<br \/>\n      tocSelector: '.toc',<br \/>\n      contentSelector: '.post-content',<br \/>\n      headingSelector: 'h1, h2, h3, h4',<br \/>\n      scrollSmooth: true<br \/>\n    });<br \/>\n  });<br \/>\n&lt;\/script&gt;<\/code><\/code><\/p>\n<p><code>contentSelector<\/code>\u304c\u3001\u6295\u7a3f\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30c6\u30fc\u30de\u3067\u6307\u5b9a\u3055\u308c\u305f\u30af\u30e9\u30b9\u3068\u4e00\u81f4\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u3088\u304f\u4f7f\u7528\u3055\u308c\u308b\u30af\u30e9\u30b9\u306b\u306f<code>.post-content<\/code>\u3001\u3001\u3001<code>.gh-content<\/code>\u307e\u305f\u306f \u304c\u542b\u307e\u308c\u307e\u3059<code>.c-content<\/code>\u3002<\/p>\n<ul>\n<li>\u6700\u5f8c\u306b\u3001\u8a2d\u5b9a\u306e\u5909\u66f4\u3092\u4fdd\u5b58\u3057\u307e\u3059<code>Code injection<\/code>\u3002<\/li>\n<\/ul>\n<h2 id=\"adding-the-toc-placeholder-to-posts\">\u6295\u7a3f\u306b\u76ee\u6b21\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u30fc\u3092\u633f\u5165\u3059\u308b<\/h2>\n<p>\u8a18\u4e8b\u5185\u306b\u76ee\u6b21\u3092\u8868\u793a\u3059\u308b\u306b\u306f\u3001\u76ee\u7684\u306e\u5834\u6240\u306b\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u30fc\u3092\u914d\u7f6e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>TOC \u3092\u542b\u3081\u305f\u3044\u6295\u7a3f\u3092\u7de8\u96c6\u3057\u307e\u3059\u3002<\/li>\n<li><code>\/html<\/code>\u30a8\u30c7\u30a3\u30bf\u30fc\u306b\u5165\u529b\u3057\u3066\u3001\u5e0c\u671b\u306e\u5834\u6240\u306b HTML \u30ab\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/li>\n<li>\u6b21\u306e\u30b3\u30fc\u30c9\u3092 HTML \u30ab\u30fc\u30c9\u306b\u542b\u3081\u307e\u3059\u3002<\/li>\n<\/ul>\n<p> <code> <code>&lt;div class=\"toc\"&gt;&lt;\/div&gt;<\/code><\/code><\/p>\n<figure class=\"wp-block-image\"><img alt=\"\" class=\"wp-image\" decoding=\"async\" height=\"479\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/10\/image-507.webp\" title=\"\" width=\"1135\"\/><\/figure>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u306b\u3088\u308a\u3001\u76ee\u6b21\u7528\u306e\u30b9\u30da\u30fc\u30b9\u304c\u78ba\u4fdd\u3055\u308c\u307e\u3059\u3002\u6295\u7a3f\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001TOCBOT \u306f\u3001\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u898b\u51fa\u3057\u304b\u3089\u6d3e\u751f\u3057\u305f\u52d5\u7684\u306b\u751f\u6210\u3055\u308c\u305f\u76ee\u6b21\u3092\u3053\u306e\u30b9\u30da\u30fc\u30b9\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<h2 id=\"styling-the-toc\">\u76ee\u6b21\u306e\u5916\u89b3\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b<\/h2>\n<p>\u30c6\u30fc\u30de\u306e\u30c7\u30b6\u30a4\u30f3\u306b\u5408\u308f\u305b\u3066 TOC \u306e\u5916\u89b3\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u304d\u307e\u3059\u3002<\/p>\n<ul>\n<li><code>Site Header<\/code>\u306e\u4e0b\u306b<code>Settings &gt; Code injection<\/code>\u3001 \u30bf\u30b0\u3067\u56f2\u307e\u308c\u305f\u30ab\u30b9\u30bf\u30e0 CSS \u30b9\u30bf\u30a4\u30eb\u3092\u8ffd\u52a0\u3057\u307e\u3059<code>&lt;style&gt;<\/code>\u3002<\/li>\n<\/ul>\n<p> <code> <code>&lt;style&gt;<br \/>\n . toc {<br \/>\n    padding: 20px;<br \/>\n    border: 1px solid #e0e0e0;<br \/>\n    background-color: #f9f9f9;<br \/>\n    border-radius: 5px;<br \/>\n  }<br \/>\n . toc a {<br \/>\n    text-decoration: none;<br \/>\n    color: #333;<br \/>\n  }<br \/>\n . toc a:hover {<br \/>\n    text-decoration: underline;<br \/>\n  }<br \/>\n&lt;\/style&gt;<\/code><\/code><\/p>\n<p>\u597d\u307f\u306b\u5408\u308f\u305b\u3066\u3053\u308c\u3089\u306e\u30b9\u30bf\u30a4\u30eb\u3092\u81ea\u7531\u306b\u8abf\u6574\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2 id=\"adjusting-for-different-themes\">\u3055\u307e\u3056\u307e\u306a\u30c6\u30fc\u30de\u306b\u5408\u308f\u305b\u3066\u5909\u66f4<\/h2>\n<p>\u30c6\u30fc\u30de\u306f\u30b3\u30f3\u30c6\u30f3\u30c4 \u30bb\u30af\u30b7\u30e7\u30f3\u306b\u7570\u306a\u308b\u30af\u30e9\u30b9\u540d\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3042\u308b\u305f\u3081\u3001<code>contentSelector<\/code>TOCBOT \u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u306e \u304c\u30c6\u30fc\u30de\u306e\u30b3\u30f3\u30c6\u30f3\u30c4 \u30af\u30e9\u30b9\u3068\u4e00\u81f4\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li>\u958b\u3044\u3066\u3044\u308b\u6295\u7a3f\u304b\u3089\u59cb\u3081\u3066\u30c6\u30fc\u30de\u3092\u691c\u67fb\u3057\u307e\u3059\u3002<\/li>\n<li>\u6295\u7a3f\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3001<code>Inspect<\/code>\u30d6\u30e9\u30a6\u30b6\u306e\u958b\u767a\u8005\u30c4\u30fc\u30eb\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/li>\n<li>\u6295\u7a3f\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u542b\u3080\u8981\u7d20\u306b\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30af\u30e9\u30b9\u540d ( \u306a\u3069) \u3092\u898b\u3064\u3051\u307e\u3059<code>.post-content<\/code>\u3002<\/li>\n<\/ul>\n<figure class=\"wp-block-image\"><img alt=\"\" class=\"wp-image\" decoding=\"async\" height=\"420\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/10\/image-506.webp\" title=\"\" width=\"942\"\/><\/figure>\n<ul>\n<li><code>contentSelector<\/code>\u767a\u898b\u3057\u305f\u5185\u5bb9\u306b\u57fa\u3065\u3044\u3066\u3001TOCBOT \u30b9\u30af\u30ea\u30d7\u30c8\u5185\u306e \u3092\u5fc5\u305a\u66f4\u65b0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n<\/ul>\n<h2 id=\"making-the-toc-sticky\">\u30b9\u30c6\u30a3\u30c3\u30ad\u30fc\u76ee\u6b21\u306e\u4f5c\u6210<\/h2>\n<p>\u8aad\u8005\u304c\u30b9\u30af\u30ed\u30fc\u30eb\u3057\u3066\u3044\u308b\u9593\u3082\u76ee\u6b21\u3092\u8868\u793a\u3057\u7d9a\u3051\u308b\u306b\u306f\u3001\u76ee\u6b21\u3092\u56fa\u5b9a\u3059\u308b\u3088\u3046\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u3067<code>Site Header<\/code>\u3001 \u30bf\u30b0\u5185\u306b\u6b21\u306e CSS \u3092\u8ffd\u52a0\u3057\u307e\u3059<code>&lt;style&gt;<\/code>\u3002<\/li>\n<\/ul>\n<p> <code> <code>&lt;style&gt;<br \/>\n . toc {<br \/>\n    position: sticky; top: 20px;<br \/>\n  }<br \/>\n&lt;\/style&gt;<\/code><\/code><\/p>\n<p>\u3053\u308c\u306b\u3088\u308a\u3001\u30d3\u30e5\u30fc\u30dd\u30fc\u30c8\u306b\u5fdc\u3058\u3066\u76ee\u6b21\u304c\u914d\u7f6e\u3055\u308c\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u6295\u7a3f\u3092\u30b9\u30af\u30ed\u30fc\u30eb\u3057\u3066\u3082\u76ee\u6b21\u304c\u5e38\u306b\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306e\u624b\u9806\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u3001\u6a5f\u80fd\u7684\u306a\u76ee\u6b21\u3092\u4f7f\u7528\u3057\u3066 Ghost \u30d6\u30ed\u30b0\u3092\u5145\u5b9f\u3055\u305b\u3001\u6295\u7a3f\u5168\u4f53\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u3068\u8aad\u8005\u306e\u30a4\u30f3\u30bf\u30e9\u30af\u30b7\u30e7\u30f3\u3092\u5f37\u5316\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a class=\"xiaomi\" href=\"https:\/\/allthings.how\/how-to-add-table-of-contents-toc-to-any-ghost-theme\/\" rel=\"noopener noreferrer nofollow\" target=\"_blank\">\u30bd\u30fc\u30b9<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ghost \u30d6\u30ed\u30b0\u306b\u76ee\u6b21 (TOC) \u3092\u7d44\u307f\u8fbc\u3080\u3068\u3001\u9577\u3044\u8a18\u4e8b\u3092\u30b7\u30fc\u30e0\u30ec\u30b9\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3067\u304d\u308b\u305f\u3081\u3001\u8aad\u8005\u306e\u30a8\u30af\u30b9\u30da\u30ea\u30a8\u30f3\u30b9\u304c\u5927\u5e45\u306b\u5411\u4e0a\u3057\u307e\u3059\u3002\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001\u6295\u7a3f\u5185\u306e\u898b\u51fa\u3057\u304b\u3089 TOC \u3092\u81ea\u52d5\u7684\u306b\u751f\u6210\u3059\u308b JavaScript \u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u3042\u308b TOCBOT \u3092\u4f7f\u7528\u3057\u3066\u3001\u4efb\u610f\u306e Ghost \u30c6\u30fc\u30de\u306b TOC \u3092\u8ffd\u52a0\u3059\u308b\u624b\u9806\u3092\u8aac\u660e\u3057\u307e\u3059\u3002 TOCBOT \u3092 Ghost \u306b\u7d71\u5408\u3059\u308b TOCBOT \u306f\u3001\u6295\u7a3f\u306e\u898b\u51fa\u3057\u304b\u3089\u52b9\u7387\u7684\u306b\u76ee\u6b21\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u7c21\u5358\u306a\u624b\u9806\u306b\u5f93\u3063\u3066\u304f\u3060\u3055\u3044\u3002 Ghost \u7ba1\u7406\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u3001 \u306b\u79fb\u52d5\u3057\u307e\u3059Settings &gt; Code injection\u3002 \u3053\u306eSite Header\u9818\u57df\u306b\u3001\u5fc5\u8981\u306a TOCBOT \u30b9\u30af\u30ea\u30d7\u30c8\u3068\u30b9\u30bf\u30a4\u30eb\u30b7\u30fc\u30c8\u3092\u633f\u5165\u3057\u307e\u3059\u3002 &lt;script type=&#8221;text\/javascript&#8221;src=&#8221;https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/tocbot\/4.21.0\/tocbot.min.js&#8221;&gt;&lt;\/script&gt; &lt;link href=&#8221;https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/tocbot\/4.21.0\/tocbot.css&#8221;rel=&#8221;stylesheet&#8221;&gt; \u6b21\u306b\u3001Site Footer\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u3001\u6b21\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f7f\u7528\u3057\u3066 TOCBOT \u3092\u521d\u671f\u5316\u3057\u307e\u3059\u3002 &lt;script&gt; document.addEventListener(&#8216;DOMContentLoaded&#8217;, function() { tocbot.init({ tocSelector: &#8216;.toc&#8217;, contentSelector: &#8216;.post-content&#8217;, headingSelector: &#8216;h1, h2, h3, h4&#8217;, scrollSmooth: true }); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[127],"class_list":["post-4980","post","type-post","status-publish","format-standard","hentry","category-how-to","tag-microsoft"],"acf":[],"_links":{"self":[{"href":"https:\/\/howtogeek.blog\/ja\/wp-json\/wp\/v2\/posts\/4980","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/howtogeek.blog\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/howtogeek.blog\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/howtogeek.blog\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/howtogeek.blog\/ja\/wp-json\/wp\/v2\/comments?post=4980"}],"version-history":[{"count":1,"href":"https:\/\/howtogeek.blog\/ja\/wp-json\/wp\/v2\/posts\/4980\/revisions"}],"predecessor-version":[{"id":4981,"href":"https:\/\/howtogeek.blog\/ja\/wp-json\/wp\/v2\/posts\/4980\/revisions\/4981"}],"wp:attachment":[{"href":"https:\/\/howtogeek.blog\/ja\/wp-json\/wp\/v2\/media?parent=4980"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/howtogeek.blog\/ja\/wp-json\/wp\/v2\/categories?post=4980"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/howtogeek.blog\/ja\/wp-json\/wp\/v2\/tags?post=4980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}