hugo/content/en/content-management/formats.md
Bjørn Erik Pedersen aa5ac36a3e Squashed 'docs/' changes from 327003421..39a7fac34
39a7fac34 Add .hugo_build.lock to .gitignore
920c716a4 fix a typo: to -> two (#1545)
6f0ba9593 Remove godocref from front matter (#1543)
8ec3d5948 remove link to wercker (#1544)
b56008719 Delete deployment-with-wercker.md (#1542)
e33d29b02 Fix broken links (#1538)
29e9d4c21 Sort commenting systems (#1541)
0b7ea60a7 Delete the news page "HTTP/2 Server Push in Hugo"
6e1515857 Fix quick-start.md (#1525)
62168ab35 Update comments.md (#1535)
d92191512 Small typo (#1539)
129c8834a Correct the PostCSS noMap default value (#1534)
6a5b29fcc Add example to index function (#1536)
e3dd8c507 Update output-formats.md
0c9321ca0 Remove reference to using LiveReload in production environment
4072d6776 Mod testing
09fabf7d6 Fix typo (#1524)
2fce813c8 Fix grammatical error in quick-start.md (#1523)
45230ab4a Hugo Mod testing
2dd4cd9e7 Update index.md
2c3ed62fd netlify: Bump to 0.88.1
648e2a007 Merge branch 'tempv0.88.1'
f216eade1 releaser: Add release notes to /docs for release of 0.88.1
8a7b64d4b Fix typographical errors in 0.88.0 release notes
a4bf86300 Release 0.88
738bb8f38 releaser: Add release notes to /docs for release of 0.88.0
8fcf2c55d highlight: Remove some pygments references
f2b173de2 HTTPS link
c88881c8e Adding link to nginx documentation
6b0a74fe0 Fix typos in docs (#1516)
498b8f0f1 Fix typos in time.Format (#1515)
28723fad6 Fix taxonomy and term examples (#1514)
3ffd00e12 Update front-matter.md
7cc1da82e Fix grammar in 0.86.1 release notes (#1510)
0009c51c3 Update docs helper
7e2f430f4 Update index.md
7857eae7e releaser: Add release notes to /docs for release of 0.87.0
1f08b684b releaser: Add release notes to /docs for release of 0.87.0
36a9e701c docs: Adjust config docs
0f588438e docs: Regen CLI docs
1b4682cd8 docs: Regen docs helper
bc8bbaae9 Merge commit 'bd77f6e1c99e04a476f0b1bb4e44569134e02399' into release-0.87.0
6f2480643 docs: Adjust time zone docs

git-subtree-dir: docs
git-subtree-split: 39a7fac343c289906db644c96079fdcc0298582f
2021-10-31 13:51:51 +01: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: