Qiita Conference 2025

みのるん (@minorun365)

30代からでも遅くない! 内製開発の世界に飛び込み、最前線で戦うLLMアプリ開発エンジニアになろう

6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Octopressで見出しタグを目次にする方法

Last updated at Posted at 2014-07-07

jekyll-toc-generatorというプラグインが使えますが、Octopressで使うと、ちょっとだけ不都合があったので、変更しました。

https://github.com/syui/jekyll-toc-generator

$ echo "gem 'nokogiri'" >> ~/octopress/Gemfile

$ cd ~/octopress

$ bundle install

$ cd ~/octopress/plugins/

$ curl -O https://raw.githubusercontent.com/syui/jekyll-toc-generator/master/_plugins/tocGenerator.rb

あとは、個別ページやメインページなど表示したい場所で{{ content }}{{ content | toc_generate }}に変更します。

source/_includes/article.html
- <div class="entry-content">{{ content }}</div>

+ <div class="entry-content">{{ content | toc_generate }}</div>

なお、有効無効の設定は、noToc: trueのオプションになります。デフォルトでは有効なので、無効にする設定です。

---
layout: post
noToc: true
---

これで、目次が自動形成されていい感じです。

参考:

Octopressで見出しの目次を作る方法 改 - 割り箸ポテチ

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?