Usage no npm install needed!

<script type="module">
  import hexoRendererPandoc from 'https://cdn.skypack.dev/hexo-renderer-pandoc';



npm npm

Yet another markdown renderer plugin for Hexo. It can converts Pandoc's markdown to HTML. If you want, it can also be a renderer for textile, reStructedText, etc.


  1. Firstly, make sure you have installed pandoc (version >= 2.0).
  2. Secondly, cd into your hexo root folder and execute the following command:
$ npm install hexo-renderer-pandoc --save

This will install hexo-renderer-pandoc.


By default, this plugin issues command pandoc to invoke pandoc. If your pandoc executable is not in your search path environment variable, you can override this command through _config.yml.

  pandoc_path: C:/Program Files/Pandoc/pandoc.exe

Using absolute path is recommended.

The path depends on your operation system. So even if you are using the git-bash shell on Windows, you need the Windows path like the one in the example.

hexo-renderer-pandoc can not only render markdown, but also supports textile, reStructedText and many other formats, due to the strong capability of pandoc.

By default, it only renders Pandoc-markdown. But if you want to make it be a textile renderer instead of a markdown renderer, simply modify the args from the index.js as:

var args = [ '-f', 'textile', '-t', 'html', '--mathjax', '--smart'];

and change the register line as:

hexo.extend.renderer.register('textile', 'html', pandoc);

You can pass additional arguments to pandoc through _config.yml. The default configuration is:

  • filters is a list of any pandoc filter installed on your path.
  • extra is a list of mappings:
  - key: value

passed to pandoc as --key value.

  • template is a template file you wish to use when pandoc generates your posts:
template: dir/.../template.html

will be passed to pandoc as --template=dir/../template.html

The path of the template should be relative to the root of your blog.

For example, the very simple template

<div id="$idprefix$TOC">

prepends table of contents to all your posts if variable --toc is also passed. To enable TOC, add to your _config.yml:

  # other options
    - toc: # will be passed as `--toc`. Note the colon
  template: dir/../template.html
  • meta is a list of anything you wish to be sent to pandoc as meta:
  - key: value1
  - value2

would be passed as -M key=value1 -M value2.

pandoc-citeproc for example can be configured as:

    - pandoc-citeproc
    - bibliography: "/path/to/bibfile.bib"
    - suppress-bibliography
  • mathEngine is an option for choosing math engine. By default, mathEngine is mathjax.

For example, if you want to use KaTeX, you can pass katex to the mathEngine option:

  mathEngine: katex

Then, the args of pandoc is this: [..., "--katex", ...] .

Issues related to Hexo Tags

There are issues related to Hexo tags. If you are using them, this section may be at your concern.

Here we are referring to this sort of tags, not post tags

Mechanism of Tag Rendering

This function takes care of post rendering.

The rendering of a post takes the following steps:

  1. Since Swig Tags (things like {% %}) are not part of legal Markdown, all Swig Tags are "escaped", i.e., extracted from the post and each replaced with a unique marker.

  2. The post, now contains only legal Markdown, is rendered without any tag, by calling this plugin.

  3. Tags are separately rendered as Markdown, also by calling this plugin.

  4. Rendered tags are inserted back to the post, each to the position of its unique marker.

Note tags can be nested.

Issues arise as tags are rendered with separate calls to this plugin. One being when using Pandoc templates to add header/footer, we only want the template to be used if we are rendering a post. An other similar issue is some Pandoc filters also needs to know whether they are rendering a standalone post, or just a fragment.

Since Hexo calls this plugin without telling whether it want us to render a standalone post, we attempt to figure this out ourselves. Looking at the source code of Hexo, we found that if we are rendering a post, data has the key path , otherwise (e.g., rendering a tag), path is not present in data . We are currently only aware of one situation when we are not rendering a standalone post, i.e., when we are rendering a tag.

What to be Aware of when Using Tags


Currently templates are only applied when rendering standalone posts. If there is any need to also apply templates (possibly a different set applied to posts) to tags, please submit an issue report to request this functionality, we'd be happy to discuss on how it should behave and implement it.


Due to how tags are rendered, content of each tag has its own "scope". When rendering a tag, Pandoc sees neither other tags contained in it, nor the context where it is contained. One implication of which is when using footnotes, one has to be aware of that a footnote reference and its definition has to be in the same tag. Even when one thing is in the tag nested in where the other is, is illegal.

For example, the following is illegal.

{% tag %}
{% tag %}
[^1]: definition of footnote 1
{% endtag%}
{% endtag%}

The following is legal, as all three definitions are in different scopes.

{% tag %}
{% tag %}
[^1]: definition of footnote 1
{% endtag%}
[^1]: definition of footnote 1
{% endtag%}

{% tag %}
[^1]: definition of footnote 1
{% endtag%}

Pandoc Filters

we passed the argument -M standalone=[True|False] to Pandoc. If a Pandoc Filter desires to know whether it is applied on an standalone post, it can check the metavariable standalone.

As an example, when using Panflute, this metavariable can be accessed by

doc.get_metadata("standalone", True)

We recommend to assume rendering standalone post when this metavariable is not set for backward compatibility.


I'd like to thank John MacFarlane for creating Pandoc and John Gruber for developing Markdown. Also, this work is based on @pvorb (Paul Vorbach) 's node-pdc wrapper for pandoc.

Special credit for @RichardYan314 as a good maintainer for this project!