vuepress search h4

Vuepress’ default theme only searches h1 to h3.

The default vuepress theme comes with header based search powered by @vuepress/plugin-search. This search plugin operates on the Vue Page object, which has a $page.headers property (docs).

The headers are extracted and added to the page object at build-time. By default only h1, h2, and h3 headers are extracted.

To change the headers that are included in the $page you can add an markdown.extractHeaders option to .vuepress/config.js.

1
2
3
4
5
6
7
module.exports = {
  // trimmed, existing config

  markdown: {extractHeaders: ['h2', 'h3', 'h4']},

  // trimmed
}

For vuepress2;

1
2
3
4
5
6
7
8
9
module.exports = {
  // trimmed, existing config

  markdown: {
    extractHeaders: {level: [2, 3, 4]}
  },

  // trimmed
}