Debian Codegraph @

docs/content/en/content-management/formats.md

raw
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 Hugo supports the following content formats.
31
32 ### Markdown
33
34 Create your content in [Markdown][] preceded by front matter.
35
36 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].
37
38 Hugo provides custom Markdown features including:
39
40 [Attributes][]
41 : 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.
42
43 [Extensions][]
44 : Leverage the embedded Markdown extensions to create tables, definition lists, footnotes, task lists, inserted text, mark text, subscripts, superscripts, and more.
45
46 [Mathematics][]
47 : Include mathematical equations and expressions in Markdown using LaTeX markup.
48
49 [Render hooks][]
50 : 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.
51
52 ### HTML
53
54 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.
55
56 > [!NOTE]
57 > The HTML content format is denied by default. See [`security.allowContent`][].
58
59 ### Emacs Org Mode
60
61 Create your content in the [Emacs Org Mode][] format preceded by front matter. You can use Org Mode keywords for front matter. See [details][].
62
63 > [!NOTE]
64 > The Emacs Org Mode content format is denied by default. See [`security.allowContent`][].
65
66 ### AsciiDoc
67
68 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.
69
70 > [!NOTE]
71 > 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.
72
73 You can configure the AsciiDoc renderer in your [project configuration][configure asciidoc].
74
75 In its default configuration, Hugo passes these CLI flags when calling the `asciidoctor` executable:
76
77 ```sh
78 --no-header-footer
79 ```
80
81 The CLI flags passed to the `asciidoctor` executable depend on configuration. You may inspect the flags when building your project:
82
83 ```sh
84 hugo build --logLevel info
85 ```
86
87 ### Pandoc
88
89 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.
90
91 > [!NOTE]
92 > 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.
93
94 The CLI flags that Hugo passes when calling the `pandoc` executable depend on the installed Pandoc version.
95
96 If the installed version supports the `--math-method` flag introduced in Pandoc 3.11:
97
98 ```sh
99 --citeproc --math-method=mathjax
100 ```
101
102 Otherwise:
103
104 ```sh
105 --citeproc --mathjax
106 ```
107
108 {{< new-in 0.164.0 />}}
109
110 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:
111
112 ```md {file="content/example.pdc"}
113 ---
114 title: home
115 ---
116
117 This is a paragraph followed by a metadata block.
118
119 ---
120 bibliography: foo.bib
121 citation-style: ieee.csl
122 link-citations: true
123 ---
124
125 This is a citation: @einstein1905physics
126
127 This is another citation: [@WatsonCrick1953, p. 33]
128 ```
129
130 > [!NOTE]
131 > 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.
132
133 ### reStructuredText
134
135 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.
136
137 > [!NOTE]
138 > 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.
139
140 Hugo passes these CLI flags when calling the `rst2html` executable:
141
142 ```sh
143 --leave-comments --initial-header-level=2
144 ```
145
146 ## Classification
147
148 {{% include "/_common/content-format-table.md" %}}
149
150 When converting content to HTML, Hugo uses:
151
152 - Native renderers for Markdown, HTML, and Emacs Org Mode
153 - External renderers for AsciiDoc, Pandoc, and reStructuredText
154
155 Native renderers are faster than external renderers.
156
157 [AsciiDoc]: https://asciidoc.org/
158 [Attributes]: /content-management/markdown-attributes/
159 [CommonMark]: https://spec.commonmark.org/current/
160 [Docutils]: https://docutils.sourceforge.io/
161 [Emacs Org Mode]: https://orgmode.org/
162 [Extensions]: /configuration/markup/#extensions
163 [GitHub Flavored Markdown]: https://github.github.com/gfm/
164 [Goldmark]: https://github.com/yuin/goldmark
165 [HTML]: https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started/Your_first_website/Creating_the_content
166 [Markdown]: https://daringfireball.net/projects/markdown/
167 [Mathematics]: /content-management/mathematics/
168 [Pandoc]: https://pandoc.org/MANUAL.html#pandocs-markdown
169 [Render hooks]: /render-hooks/introduction/
170 [`security.allowContent`]: /configuration/security/#allowcontent
171 [`security.exec.allow`]: /configuration/security/#execallow
172 [configure asciidoc]: /configuration/markup/#asciidoc
173 [configure goldmark]: /configuration/markup/#goldmark
174 [details]: /content-management/front-matter/#emacs-org-mode
175 [front matter]: /content-management/front-matter/
176 [reStructuredText]: https://docutils.sourceforge.io/rst.html