hugo/content/en/content-management/formats.md
Bjørn Erik Pedersen 07b8d9466d Squashed 'docs/' changes from 9cece6640..fb551cc75
fb551cc75 Update index.md
7af894857 Update index.md
d235753ea Hugo 0.82.1
e03e72deb Merge branch 'temp0821'
e62648961 Merge branch 'release-0.82.1'
e1ab0f6eb releaser: Add release notes to /docs for release of 0.82.1
5d354c38d Replaced ``` code blocks with Code Toggler
c9d065c20 Remove duplicate YAML keys (#1420)
8ae31e701 Add webp image encoding support
848f2af26 Update internal.md (#1407)
c103a86a4 Fix `ref` shortcode example output (#1409)
9f8ba56dc Remove leading dot from where function KEY (#1419)
363251a51 Improve presentation of template lookup order (#1382)
b73da986d Improve description of Page Resources (#1381)
4e0bb96d5 Rework robots.txt page (#1405)
edf893e6f Update migrations.md (#1412)
450f1580b Add link to `site` function doc (#1417)
cfffa6e6f Added one extension to the list (#1414)
05f1665a0 Update theme
5de0b1c6a Update theme
250e20552 Add hugo.IsExtended
dea5e1fd7 Fix typo on merge function page (#1408)
1bbed2cf3 Update configuration.md
be0b64a46 Omit ISO
cbb5b8367 Fix `dateFormat` documentation
698f15466 Regenerate the docshelper
f9a8a7cb6 Update multilingual.md
a22dc6267 Fix grammar (#1398)
eb98b0997 Fix pretty URL example (#1397)
f4c4153dc Mention date var complementation in post scheduling (#1396)
17fae284c Fix resources.ExecuteAsTemplate argument order (#1394)
97e2c2abb Use code-toggle shortcode in `multilingual.md` (#1388)
3a84929bb Harmonize capitalization (#1393)
17f15daa6 fix file naming used in example (#1392)
5d97b6a18 Add slice syntax to sections permalinks config
00665b97b Improve description of `site.md`
edcf5e3fc Fix example in `merge.md`
f275ab778 Update postprocess.md
9593e3991 Fix file name
59bd9656f Update postprocess.md
1172fb6d0 Update to theNewDynamic repository (#1263)
f5b5c1d2c Update Hugo container image
4f2e92f2a Adapt anchorize.md to Goldmark
98aa19073 Directly link to `highlight` shortcode (#1384)
4c75c2422 Fix header level
f15c06f23 markdownify: add note about render-hooks and .RenderString (#1281)
69c82eb68 Remove Blackfriday reference from shortcode desc (#1380)
36de478df Update description of ignoreFiles config setting (#1377)
6337699d8 Remove "Authors" page from documentation (#1371)
35e73ca90 fix indent in example (#1372)
d3f01f19a Remove opening body tag from header example (#1376)
341a5a7d8 Update index.md
c9bfdbee6 Release 0.82.0
119644949 releaser: Add release notes to /docs for release of 0.82.0
32efaed78 docs: Regenerate docs helper
dea5449a2 docs: Regen CLI docs
eeab18fce Merge commit '81689af79901f0cdaff765cda6322dd4a9a7ccb3'
d508a1259 Attributes for code fences should be placed after the lang indicator only
c80905cef deps: Update to esbuild v0.9.0
95350eb79 Add support for Google Analytics v4
02d36f9bc Allow markdown attribute lists to be used in title render hooks
7df220a64 Merge commit '9d31f650da964a52f05fc27b7fb99cf3e09778cf'
d80bf61b7 Fixes #7698.

git-subtree-dir: docs
git-subtree-split: fb551cc750faa83a1493b0e0d0898cd98ab74465
2021-04-20 20:21:45 +02:00

8.7 KiB

title linktitle description date publishdate lastmod categories keywords menu weight draft aliases toc
Content Formats Content Formats Both HTML and Markdown are supported content formats. 2017-01-10 2017-01-10 2017-04-06
content management
markdown
asciidoc
mmark
pandoc
content format
docs
parent weight
content-management 20
20 false
/content/markdown-extras/
/content/supported-formats/
/doc/supported-formats/
true

You can put any file type into your /content directories, but Hugo uses the markup front matter value if set or the file extension (see Markup identifiers in the table below) to determine if the markup needs to be processed, e.g.:

  • Markdown converted to HTML
  • Shortcodes processed
  • Layout applied

List of content formats

The current list of content formats in Hugo:

Name Markup identifiers Comment
Goldmark md, markdown, goldmark Note that you can set the default handler of md and markdown to something else, see Configure Markup.{{< new-in "0.60.0" >}}
Blackfriday blackfriday Blackfriday will eventually be deprecated.
MMark mmark Mmark is deprecated and will be removed in a future release.
Emacs Org-Mode org See go-org.
AsciiDoc asciidocext, adoc, ad Needs Asciidoctor installed.
RST rst Needs RST installed.
Pandoc pandoc, pdc Needs Pandoc installed.
HTML html, htm To be treated as a content file, with layout, shortcodes etc., it must have front matter. If not, it will be copied as-is.

The markup identifier is fetched from either the markup variable in front matter or from the file extension. For markup-related configuration, see Configure Markup.

External Helpers

Some of the formats in the table above need external helpers installed on your PC. For example, for AsciiDoc files, Hugo will try to call the asciidoctor command. This means that you will have to install the associated tool on your machine to be able to use these formats.

Hugo passes reasonable default arguments to these external helpers by default:

  • asciidoctor: --no-header-footer -
  • rst2html: --leave-comments --initial-header-level=2
  • pandoc: --mathjax

{{% warning "Performance of External Helpers" %}} Because additional formats are external commands, generation performance will rely heavily on the performance of the external tool you are using. As this feature is still in its infancy, feedback is welcome. {{% /warning %}}

External Helper AsciiDoc

AsciiDoc implementation EOLs in Jan 2020 and is no longer supported. AsciiDoc development is being continued under Asciidoctor. The format AsciiDoc remains of course. Please continue with the implementation Asciidoctor.

External Helper Asciidoctor

The Asciidoctor community offers a wide set of tools for the AsciiDoc format that can be installed additionally to Hugo. See the Asciidoctor docs for installation instructions. Make sure that also all optional extensions like asciidoctor-diagram or asciidoctor-html5s are installed if required.

{{% note %}} External asciidoctor command requires Hugo rendering to disk to a specific destination directory. It is required to run Hugo with the command option --destination. {{% /note %}}

Some Asciidoctor parameters can be customized in Hugo:

Parameter Comment
backend Don't change this unless you know what you are doing.
doctype Currently, the only document type supported in Hugo is article.
extensions Possible extensions are asciidoctor-html5s, asciidoctor-bibtex, asciidoctor-diagram, asciidoctor-interdoc-reftext, asciidoctor-katex, asciidoctor-latex, asciidoctor-mathematical, asciidoctor-question, asciidoctor-rouge.
attributes Variables to be referenced in your AsciiDoc file. This is a list of variable name/value maps. See Asciidoctor's attributes.
noHeaderOrFooter Output an embeddable document, which excludes the header, the footer, and everything outside the body of the document. Don't change this unless you know what you are doing.
safeMode Safe mode level unsafe, safe, server or secure. Don't change this unless you know what you are doing.
sectionNumbers Auto-number section titles.
verbose Verbosely print processing information and configuration file checks to stderr.
trace Include backtrace information on errors.
failureLevel The minimum logging level that triggers a non-zero exit code (failure).

Hugo provides additional settings that don't map directly to Asciidoctor's CLI options:

workingFolderCurrent
Sets the working directory to be the same as that of the AsciiDoc file being processed, so that include will work with relative paths. This setting uses the asciidoctor cli parameter --base-dir and attribute outdir=. For rendering diagrams with asciidoctor-diagram, workingFolderCurrent must be set to true.
preserveTOC
By default, Hugo removes the table of contents generated by Asciidoctor and provides it through the built-in variable .TableOfContents to enable further customization and better integration with the various Hugo themes. This option can be set to true to preserve Asciidoctor's TOC in the generated page.

Below are all the AsciiDoc related settings in Hugo with their default values:

{{< code-toggle config="markup.asciidocExt" />}}

Notice that for security concerns only extensions that do not have path separators (either \, / or .) are allowed. That means that extensions can only be invoked if they are in one's ruby's $LOAD_PATH (ie. most likely, the extension has been installed by the user). Any extension declared relative to the website's path will not be accepted.

Example of how to set extensions and attributes:

[markup.asciidocExt]
    extensions = ["asciidoctor-html5s", "asciidoctor-diagram"]
    workingFolderCurrent = true
    [markup.asciidocExt.attributes]
        my-base-url = "https://example.com/"
        my-attribute-name = "my value"

In a complex Asciidoctor environment it is sometimes helpful to debug the exact call to your external helper with all parameters. Run Hugo with -v. You will get an output like

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 -] ...

Learn Markdown

Markdown syntax is simple enough to learn in a single sitting. The following are excellent resources to get you up and running: