| 1 |
--- |
| 2 |
title: Content formats |
| 3 |
description: Create your content using Markdown, HTML, Emacs Org Mode, AsciiDoc, Pandoc, or reStructuredText. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
aliases: [/content/markdown-extras/,/content/supported-formats/,/doc/supported-formats/] |
| 7 |
--- |
| 8 |
|
| 9 |
## Introduction |
| 10 |
|
| 11 |
You may mix content formats throughout your site. For example: |
| 12 |
|
| 13 |
```tree |
| 14 |
content/ |
| 15 |
└── posts/ |
| 16 |
├── post-1.md |
| 17 |
├── post-2.adoc |
| 18 |
├── post-3.org |
| 19 |
├── post-4.pandoc |
| 20 |
├── post-5.rst |
| 21 |
└── post-6.html |
| 22 |
``` |
| 23 |
|
| 24 |
Regardless of content format, all content must have [front matter][], preferably including both `title` and `date`. |
| 25 |
|
| 26 |
Hugo selects the content renderer based on the `markup` identifier in front matter, falling back to the file extension. See the [classification](#classification) table below for a list of markup identifiers and recognized file extensions. |
| 27 |
|
| 28 |
## Formats |
| 29 |
|
| 30 |
### Markdown |
| 31 |
|
| 32 |
Create your content in [Markdown][] preceded by front matter. |
| 33 |
|
| 34 |
Markdown is Hugo's default content format. Hugo natively renders Markdown to HTML using [Goldmark][]. Goldmark is fast and conforms to the [CommonMark][] and [GitHub Flavored Markdown][] specifications. You can configure Goldmark in your [project configuration][configure goldmark]. |
| 35 |
|
| 36 |
Hugo provides custom Markdown features including: |
| 37 |
|
| 38 |
[Attributes][] |
| 39 |
: Apply HTML attributes such as `class` and `id` to Markdown images and block elements including blockquotes, fenced code blocks, headings, horizontal rules, lists, paragraphs, and tables. |
| 40 |
|
| 41 |
[Extensions][] |
| 42 |
: Leverage the embedded Markdown extensions to create tables, definition lists, footnotes, task lists, inserted text, mark text, subscripts, superscripts, and more. |
| 43 |
|
| 44 |
[Mathematics][] |
| 45 |
: Include mathematical equations and expressions in Markdown using LaTeX markup. |
| 46 |
|
| 47 |
[Render hooks][] |
| 48 |
: Override the conversion of Markdown to HTML when rendering fenced code blocks, headings, images, and links. For example, render every standalone image as an HTML `figure` element. |
| 49 |
|
| 50 |
### HTML |
| 51 |
|
| 52 |
Create your content in [HTML][] preceded by front matter. The content is typically what you would place within an HTML document's `body` or `main` element. |
| 53 |
|
| 54 |
> [!NOTE] |
| 55 |
> The HTML content format is denied by default. See [`security.allowContent`][]. |
| 56 |
|
| 57 |
### Emacs Org Mode |
| 58 |
|
| 59 |
Create your content in the [Emacs Org Mode][] format preceded by front matter. You can use Org Mode keywords for front matter. See [details][]. |
| 60 |
|
| 61 |
### AsciiDoc |
| 62 |
|
| 63 |
Create your content in the [AsciiDoc][] format preceded by front matter. Hugo renders AsciiDoc content to HTML using the Asciidoctor executable. You must install Asciidoctor and its dependencies (Ruby) to render the AsciiDoc content format. |
| 64 |
|
| 65 |
> [!NOTE] |
| 66 |
> Hugo's default security policy does not permit execution of the `asciidoctor` binary. You must add it to the [`security.exec.allow`][] list in your project configuration. |
| 67 |
|
| 68 |
You can configure the AsciiDoc renderer in your [project configuration][configure asciidoc]. |
| 69 |
|
| 70 |
In its default configuration, Hugo passes these CLI flags when calling the Asciidoctor executable: |
| 71 |
|
| 72 |
```sh |
| 73 |
--no-header-footer |
| 74 |
``` |
| 75 |
|
| 76 |
The CLI flags passed to the Asciidoctor executable depend on configuration. You may inspect the flags when building your project: |
| 77 |
|
| 78 |
```sh |
| 79 |
hugo build --logLevel info |
| 80 |
``` |
| 81 |
|
| 82 |
### Pandoc |
| 83 |
|
| 84 |
Create your content in the [Pandoc][] format preceded by front matter. Hugo renders Pandoc content to HTML using the Pandoc executable. You must install Pandoc to render the Pandoc content format. |
| 85 |
|
| 86 |
> [!NOTE] |
| 87 |
> Hugo's default security policy does not permit execution of the `pandoc` binary. You must add it to the [`security.exec.allow`][] list in your project configuration. |
| 88 |
|
| 89 |
Hugo passes these CLI flags when calling the Pandoc executable: |
| 90 |
|
| 91 |
```sh |
| 92 |
--citeproc --mathjax |
| 93 |
``` |
| 94 |
|
| 95 |
{{< new-in 0.164.0 />}} |
| 96 |
|
| 97 |
The `--citeproc` flag enables Pandoc's citation processing. When using Pandoc's bibliography and citations feature, control the bibliography file path, citation style, inline reference definitions, and other settings using a metadata block within the content file. For example: |
| 98 |
|
| 99 |
```md {file="content/example.pdc"} |
| 100 |
--- |
| 101 |
title: home |
| 102 |
--- |
| 103 |
|
| 104 |
This is a paragraph followed by a metadata block. |
| 105 |
|
| 106 |
--- |
| 107 |
bibliography: foo.bib |
| 108 |
citation-style: ieee.csl |
| 109 |
link-citations: true |
| 110 |
--- |
| 111 |
|
| 112 |
This is a citation: @einstein1905physics |
| 113 |
|
| 114 |
This is another citation: [@WatsonCrick1953, p. 33] |
| 115 |
``` |
| 116 |
|
| 117 |
> [!NOTE] |
| 118 |
> Bibliography files and citation style files must exist on the local file system; they cannot be imported from Hugo modules. File paths may be relative to the project root or absolute. |
| 119 |
|
| 120 |
### reStructuredText |
| 121 |
|
| 122 |
Create your content in the [reStructuredText][] format preceded by front matter. Hugo renders reStructuredText content to HTML using [Docutils][], specifically rst2html. You must install Docutils and its dependencies (Python) to render the reStructuredText content format. |
| 123 |
|
| 124 |
> [!NOTE] |
| 125 |
> Hugo's default security policy does not permit execution of the `rst2html` binary. You must add it to the [`security.exec.allow`][] list in your project configuration. |
| 126 |
|
| 127 |
Hugo passes these CLI flags when calling the rst2html executable: |
| 128 |
|
| 129 |
```sh |
| 130 |
--leave-comments --initial-header-level=2 |
| 131 |
``` |
| 132 |
|
| 133 |
## Classification |
| 134 |
|
| 135 |
{{% include "/_common/content-format-table.md" %}} |
| 136 |
|
| 137 |
When converting content to HTML, Hugo uses: |
| 138 |
|
| 139 |
- Native renderers for Markdown, HTML, and Emacs Org mode |
| 140 |
- External renderers for AsciiDoc, Pandoc, and reStructuredText |
| 141 |
|
| 142 |
Native renderers are faster than external renderers. |
| 143 |
|
| 144 |
[AsciiDoc]: https://asciidoc.org/ |
| 145 |
[Attributes]: /content-management/markdown-attributes/ |
| 146 |
[CommonMark]: https://spec.commonmark.org/current/ |
| 147 |
[Docutils]: https://docutils.sourceforge.io/ |
| 148 |
[Emacs Org Mode]: https://orgmode.org/ |
| 149 |
[Extensions]: /configuration/markup/#extensions |
| 150 |
[GitHub Flavored Markdown]: https://github.github.com/gfm/ |
| 151 |
[Goldmark]: https://github.com/yuin/goldmark |
| 152 |
[HTML]: https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started/Your_first_website/Creating_the_content |
| 153 |
[Markdown]: https://daringfireball.net/projects/markdown/ |
| 154 |
[Mathematics]: /content-management/mathematics/ |
| 155 |
[Pandoc]: https://pandoc.org/MANUAL.html#pandocs-markdown |
| 156 |
[Render hooks]: /render-hooks/introduction/ |
| 157 |
[`security.allowContent`]: /configuration/security/#allowcontent |
| 158 |
[`security.exec.allow`]: /configuration/security/#execallow |
| 159 |
[configure asciidoc]: /configuration/markup/#asciidoc |
| 160 |
[configure goldmark]: /configuration/markup/#goldmark |
| 161 |
[details]: /content-management/front-matter/#emacs-org-mode |
| 162 |
[front matter]: /content-management/front-matter/ |
| 163 |
[reStructuredText]: https://docutils.sourceforge.io/rst.html |