
a49697e53 Add private use subtag requirements to multilingual page
a5c6bb4da Add INFINI Pizza search engine
45b732efa Fix template lookup order for AMP pages
30c672d0b netlify: Hugo 0.133.1
7c766e724 Update page resources documentation
ca802fbec Document how to enable AsciiDoc syntax highlighting
c3350f4cf Update definition of falsy to include zero time.Time values
b0e5ab051 Fir typo
60f6cb63b Update migrations.md
ec52c7ba1 Improve formatting of example code
e5681ad01 Improve formatting of example code
bdf3ffc73 Clarify the various next/prev methods
b5505d22a Clarify template lookup order for shortcodes
cf8dd7034 Improve embedded.md
e5dee2651 Update transform.ToMath
4d419a128 Update pagination configuration to use new struct
05d4fd597 Update PrevInSection.md
fd33370ed Add new-in 0.133.0
f9062042f Add the new page config section
205645e97 Remove out-dated new-in
3ed3673f7 Fix typo
41df91659 Document the 'else with' construct introduced with Go 1.23
9c4697ab3 netlify: Hugo 0.133.0
62506b052 Merge branch 'temp133'
877e1bfcd Add config options page.nextPrevSortOrder/nextPrevInSectionSortOrder
eb159fe62 Update menu.md
efa7795a0 Update theme
dbe8911ad netlify: Hugo 0.132.2
2f793d328 Document passthrough render hooks
a7ce9a5e8 netlify: Hugo 0.132.1
2c137cb48 Update blockquotes.md
e0fa2f0d1 Add new-in badge to blockquote render hook page
bf42bbe6b Update references to render hooks
85a3d9958 Update theme
2dae72128 Document blockquote render hooks
8f5afb55d Update plainify return type
160f22d0e netlify: Hugo 0.132.0
82b5586fb Document transform.ToMath
1efcbcddb tpl/transform: Make Plainify and ToMath return template.HTML
31727be2e docs: Regen docshelper
88a421426 Merge commit 'a6e635ca7d
'
git-subtree-dir: docs
git-subtree-split: a49697e536ee0d477ab4e552cfa8dc74debeff27
14 KiB
title | description | categories | keywords | menu | weight | slug | toc | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Configure markup | Configure rendering of markup to HTML. |
|
|
|
50 | configuration-markup | true |
Default handler
Hugo uses Goldmark to render Markdown to HTML.
{{< code-toggle file=hugo >}} [markup] defaultMarkdownHandler = 'goldmark' {{< /code-toggle >}}
Files with the .md
or .markdown
extension are processed as Markdown, provided that you have not specified a different content format using the markup
field in front matter.
To use a different renderer for Markdown files, specify one of asciidocext
, org
, pandoc
, or rst
in your site configuration.
defaultMarkdownHandler | Description |
---|---|
asciidocext |
AsciiDoc |
goldmark |
Goldmark |
org |
Emacs Org Mode |
pandoc |
Pandoc |
rst |
reStructuredText |
To use AsciiDoc, Pandoc, or reStructuredText you must install the relevant renderer and update your security policy.
{{% note %}} Unless you need a unique capability provided by one of the alternate Markdown handlers, we strongly recommend that you use the default setting. Goldmark is fast, well maintained, conforms to the CommonMark specification, and is compatible with GitHub Flavored Markdown (GFM).
{{% /note %}}
Goldmark
This is the default configuration for the Goldmark Markdown renderer:
{{< code-toggle config=markup.goldmark />}}
Goldmark extensions
The extensions below, excluding Extras and Passthrough, are enabled by default.
Extension | Documentation | Enabled |
---|---|---|
cjk | Goldmark Extensions: CJK | ✔️ |
definitionList | PHP Markdown Extra: Definition lists | ✔️ |
extras | Hugo Goldmark Extensions: Extras | |
footnote | PHP Markdown Extra: Footnotes | ✔️ |
linkify | GitHub Flavored Markdown: Autolinks | ✔️ |
passthrough | Hugo Goldmark Extensions: Passthrough | |
strikethrough | GitHub Flavored Markdown: Strikethrough | ✔️ |
table | GitHub Flavored Markdown: Tables | ✔️ |
taskList | GitHub Flavored Markdown: Task list items | ✔️ |
typographer | Goldmark Extensions: Typographer | ✔️ |
Extras
{{< new-in 0.126.0 >}}
Enable deleted text, inserted text, mark text, subscript, and superscript elements in Markdown.
Element | Markdown | Rendered |
---|---|---|
Deleted text | ~~foo~~ |
<del>foo</del> |
Inserted text | ++bar++ |
<ins>bar</ins> |
Mark text | ==baz== |
<mark>baz</mark> |
Subscript | H~2~O |
H<sub>2</sub>O |
Superscript | 1^st^ |
1<sup>st</sup> |
To avoid a conflict when enabling the Hugo Goldmark Extras subscript extension, if you want to render subscript and strikethrough text concurrently you must:
- Disable the Goldmark strikethrough extension
- Enable the Hugo Goldmark Extras delete extension
For example:
{{< code-toggle file=hugo >}} [markup.goldmark.extensions] strikethrough = false
[markup.goldmark.extensions.extras.delete] enable = true
[markup.goldmark.extensions.extras.subscript] enable = true {{< /code-toggle >}}
Passthrough
{{< new-in 0.122.0 >}}
Enable the passthrough extension to include mathematical equations and expressions in Markdown using LaTeX or TeX typesetting syntax. See mathematics in Markdown for details.
Typographer
The Typographer extension replaces certain character combinations with HTML entities as specified below:
Markdown | Replaced by | Description |
---|---|---|
... |
… |
horizontal ellipsis |
' |
’ |
apostrophe |
-- |
– |
en dash |
--- |
— |
em dash |
« |
« |
left angle quote |
“ |
“ |
left double quote |
‘ |
‘ |
left single quote |
» |
» |
right angle quote |
” |
” |
right double quote |
’ |
’ |
right single quote |
Goldmark settings explained
Most of the Goldmark settings above are self-explanatory, but some require explanation.
duplicateResourceFiles
{{< new-in 0.123.0 >}}
(bool
) If true
, shared page resources on multilingual single-host sites will be duplicated for each language. See multilingual page resources for details. Default is false
.
{{% note %}}
With multilingual single-host sites, setting this parameter to false
will enable Hugo's embedded link render hook and embedded image render hook. This is the default configuration for multilingual single-host sites.
{{% /note %}}
parser.wrapStandAloneImageWithinParagraph
(bool
) If true
, image elements without adjacent content will be wrapped within a p
element when rendered. This is the default Markdown behavior. Set to false
when using an image render hook to render standalone images as figure
elements. Default is true
.
parser.autoHeadingIDType
(string
) The strategy used to automatically generate heading id
attributes, one of github
, github-ascii
or blackfriday
.
github
produces GitHub-compatibleid
attributesgithub-ascii
drops any non-ASCII characters after accent normalizationblackfriday
producesid
attributes compatible with the Blackfriday Markdown renderer
This is also the strategy used by the anchorize template function. Default is github
.
parser.attribute.block
(bool
) If true
, enables Markdown attributes for block elements. Default is false
.
parser.attribute.title
(bool
) If true
, enables Markdown attributes for headings. Default is true
.
renderHooks.image.enableDefault
{{< new-in 0.123.0 >}}
(bool
) If true
, enables Hugo's embedded image render hook. Default is false
.
{{% note %}} The embedded image render hook is automatically enabled for multilingual single-host sites if duplication of shared page resources is disabled. This is the default configuration for multilingual single-host sites.
{{% /note %}}
renderHooks.link.enableDefault
{{< new-in 0.123.0 >}}
(bool
) If true
, enables Hugo's embedded link render hook. Default is false
.
{{% note %}} The embedded link render hook is automatically enabled for multilingual single-host sites if duplication of shared page resources is disabled. This is the default configuration for multilingual single-host sites.
{{% /note %}}
renderer.hardWraps
(bool
) If true
, Goldmark replaces newline characters within a paragraph with br
elements. Default is false
.
renderer.unsafe
(bool
) If true
, Goldmark renders raw HTML mixed within the Markdown. This is unsafe unless the content is under your control. Default is false
.
AsciiDoc
This is the default configuration for the AsciiDoc renderer:
{{< code-toggle config=markup.asciidocExt />}}
AsciiDoc settings explained
attributes
(map
) A map of key-value pairs, each a document attributes. See Asciidoctor’s attributes.
backend
(string
) The backend output file format. Default is html5
.
extensions
(string array
) An array of enabled extensions, one or more of asciidoctor-html5s
, asciidoctor-bibtex
, asciidoctor-diagram
, asciidoctor-interdoc-reftext
, asciidoctor-katex
, asciidoctor-latex
, asciidoctor-mathematical
, or asciidoctor-question
.
{{% note %}}
To mitigate security risks, entries in the extension array may not contain forward slashes (/
), backslashes (\
), or periods. Due to this restriction, extensions must be in Ruby's $LOAD_PATH
.
{{% /note %}}
failureLevel
(string
) The minimum logging level that triggers a non-zero exit code (failure). Default is fatal
.
noHeaderOrFooter
(bool
) If true
, outputs an embeddable document, which excludes the header, the footer, and everything outside the body of the document. Default is true
.
preserveTOC
(bool
) If true
, preserves the table of contents (TOC) rendered by Asciidoctor. By default, to make the TOC compatible with existing themes, Hugo removes the TOC rendered by Asciidoctor. To render the TOC, use the TableOfContents
method on a Page
object in your templates. Default is false
.
safeMode
(string
) The safe mode level, one of unsafe
, safe
, server
, or secure
. Default is unsafe
.
sectionNumbers
(bool
) If true
, numbers each section title. Default is false
.
trace
(bool
) If true
, include backtrace information on errors. Default is false
.
verbose
(bool
)If true
, verbosely prints processing information and configuration file checks to stderr. Default is false
.
workingFolderCurrent
(bool
) If true
, sets the working directory to be the same as that of the AsciiDoc file being processed, allowing includes to work with relative paths. Set to true
to render diagrams with the asciidoctor-diagram extension. Default is false
.
AsciiDoc configuration example
{{< code-toggle file=hugo >}} [markup.asciidocExt] extensions = ["asciidoctor-html5s", "asciidoctor-diagram"] workingFolderCurrent = true [markup.asciidocExt.attributes] my-base-url = "https://example.com/" my-attribute-name = "my value" {{< /code-toggle >}}
AsciiDoc syntax highlighting
Follow the steps below to enable syntax highlighting.
- Step 1
- Set the
source-highlighter
attribute in your site configuration. For example:
{{< code-toggle file=hugo >}} [markup.asciidocExt.attributes] source-highlighter = 'rouge' {{< /code-toggle >}}
- Step 2
- Generate the highlighter CSS. For example:
rougify style monokai.sublime > assets/css/syntax.css
- Step 3
- In your base template add a link to the CSS file:
{{< code file=layouts/_default/baseof.html >}}
<head> ... {{ with resources.Get "css/syntax.css" }} {{ end }} ... </head> {{< /code >}}Then add the code to be highlighted to your markup:
[#hello,ruby]
----
require 'sinatra'
get '/hi' do
"Hello World!"
end
----
AsciiDoc troubleshooting
Run hugo --logLevel debug
to examine Hugo's call to the Asciidoctor executable:
INFO 2019/12/22 09:08:48 Rendering book-as-pdf.adoc with C:\Ruby26-x64\bin\asciidoctor.bat using asciidoc args [--no-header-footer -r asciidoctor-html5s -b html5s -r asciidoctor-diagram --base-dir D:\prototypes\hugo_asciidoc_ddd\docs -a outdir=D:\prototypes\hugo_asciidoc_ddd\build -] ...
Highlight
This is the default highlight
configuration. Note that some of these settings can be set per code block, see Syntax Highlighting.
{{< code-toggle config=markup.highlight />}}
For style
, see these galleries:
For CSS, see Generate Syntax Highlighter CSS.
Table of contents
This is the default configuration for the table of contents, applicable to Goldmark and Asciidoctor:
{{< code-toggle config=markup.tableOfContents />}}
startLevel
(int
) Heading levels less than this value will be excluded from the table of contents. For example, to exclude h1
elements from the table of contents, set this value to 2
. Default is 2
.
endLevel
(int
) Heading levels greater than this value will be excluded from the table of contents. For example, to exclude h4
, h5
, and h6
elements from the table of contents, set this value to 3
. Default is 3
.
ordered
(bool
) If true
, generates an ordered list instead of an unordered list. Default is false
.