6b00298bb Remove outdated "related example" 987f1e1cd Fix dead links (#601) 96287a20a Add config option "summaryLength" (#600) ced7f2085 Adjust Over showcase e334a6354 Add new showcase: over 10435b502 Add warning about privacy options only work with internal templates (#525) 48c6b0e4d Minor grammatical fix 684670ebc Add quote 0e9fada52 Improvements to taxonomy template examples e06c4bf73 Add syntax highlighting; consistent 4-space indentation c1cb3f081 Remove dead links for custom permalinks 3e3aefd04 Fix 0a671bc3751479e74a0a9d2132736c61d239707c d65888685 fix file name in 'Add Non-content Entries to a Menu' code toggle (#547) 1a0563857 Add Solus install guide (#590) 8a0d65b0d Update Windows Installation instructions (#564) c4348636a Fix typo 0a671bc37 Add post to menu example af14497c6 Add notes for `os.Stat` (Hugo 0.47) (#557) e49f65bb3 Singular to plural cb5608dbf Update introduction.md 30b060dff Add variable re-definition example (Hugo v0.48+) 21123967e Minor edits fac3df043 Refresh the Go Templates introduction 4a9600e92 Updating URL to how-to-guide for hosting hugo site on firebase bfaa7779c add missing word c2cb5d09b Tweak 'name: weight' to 'name: date' in example (#582) 5ea938ad6 Remove some Scratch 2708dcd57 Release 0.48 e375d0f05 Merge branch 'temp48' 75e36c160 releaser: Prepare repository for 0.49-DEV a6102f253 releaser: Add release notes to /docs for release of 0.48 41fc35db4 releaser: Bump versions for release of 0.48 64b9ecc74 Spell out the npm command for installing PostCSS 19e900a17 Improved Related Content doc fe21600e7 Merge commit '844aef544c19e9d8f529b4f8144e089d0982bb34' 844aef544 Squashed 'themes/gohugoioTheme/' changes from 66249819..68ddff44 069828db8 Update git.md d881d1433 Make default "related" behavior more explicit 60b9160eb Add docs for displaying 404 page on CloudFront b72ebc760 Add .gitattributes to /resources 000cf85f4 Make the pros/cons styling consistent for summaries; use desc list ebf1da97a Add note about outputStyle compressed e3338ee91 Triple backquote syntax fix 361962a7c Add one more Blogger to Hugo tool for Windows (.NET Framework 4.5) (#540) 066606a21 Fix wrong link about Mmark Syntax Document faee70757 Added exitwp-for-hugo 6b4108051 Add hugo-wrapper to starter-kits 4695dfba2 Added Utterances as Comments Alternatives. c7ba9e3e1 Correct typo beb850d9f Release 0.47.1 1cf417c8a Merge branch 'temp471' 0843bc46c releaser: Prepare repository for 0.48-DEV 8ff5c8b70 releaser: Add release notes to /docs for release of 0.47.1 e2353434d releaser: Bump versions for release of 0.47.1 ffb1300af Update development.md c22234ea5 netlify: Minify output 5b9191c56 Release 0.47 bfd92cf52 releaser: Prepare repository for 0.48-DEV ac7acf730 releaser: Add release notes to /docs for release of 0.47 b0096099d releaser: Bump versions for release of 0.47 86a7ae459 docs: Regenerate CLI docs d2c8b72bc Merge commit 'a95896878f4b4a79448b39ce93a4e0d3258b4a43' 84de7ef59 Merge commit '3a44bf182fed5f34621f450114083a6dd7e88a07' git-subtree-dir: docs git-subtree-split: 6b00298bb26b700281df28817b6556e7480cdd1e
14 KiB
title | linktitle | description | date | publishdate | lastmod | categories | keywords | menu | weight | draft | aliases | toc | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Supported Content Formats | Supported Content Formats | Markdown and Emacs Org-Mode have native support, and additional formats (e.g. Asciidoc) come via external helpers. | 2017-01-10 | 2017-01-10 | 2017-04-06 |
|
|
|
20 | false |
|
true |
Markdown is the main content format and comes in two flavours: The excellent Blackfriday project (name your files *.md
or set markup = "markdown"
in front matter) or its fork Mmark (name your files *.mmark
or set markup = "mmark"
in front matter), both very fast markdown engines written in Go.
For Emacs users, goorgeous provides built-in native support for Org-mode (name your files *.org
or set markup = "org"
in front matter)
{{% note "Deeply Nested Lists" %}} Before you begin writing your content in markdown, Blackfriday has a known issue (#329) with handling deeply nested lists. Luckily, there is an easy workaround. Use 4-spaces (i.e., tab) rather than 2-space indentations. {{% /note %}}
Configure BlackFriday Markdown Rendering
You can configure multiple aspects of Blackfriday as show in the following list. See the docs on Configuration for the full list of explicit directions you can give to Hugo when rendering your site.
{{< readfile file="/content/en/readfiles/bfconfig.md" markdown="true" >}}
Extend Markdown
Hugo provides some convenient methods for extending markdown.
Task Lists
Hugo supports GitHub-styled task lists (i.e., TODO lists) for the Blackfriday markdown renderer. If you do not want to use this feature, you can disable it in your configuration.
Example Task List Input
{{< code file="content/my-to-do-list.md" >}}
- a task list item
- list syntax required
- incomplete
- completed {{< /code >}}
Example Task List Output
The preceding markdown produces the following HTML in your rendered website:
<ul class="task-list">
<li><input type="checkbox" disabled="" class="task-list-item"> a task list item</li>
<li><input type="checkbox" disabled="" class="task-list-item"> list syntax required</li>
<li><input type="checkbox" disabled="" class="task-list-item"> incomplete</li>
<li><input type="checkbox" checked="" disabled="" class="task-list-item"> completed</li>
</ul>
Example Task List Display
The following shows how the example task list will look to the end users of your website. Note that visual styling of lists is up to you. This list has been styled according to the Hugo Docs stylesheet.
- a task list item
- list syntax required
- incomplete
- completed
Emojis
To add emojis directly to content, set enableEmoji
to true
in your site configuration. To use emojis in templates or shortcodes, see emojify
function.
For a full list of emojis, see the Emoji cheat sheet.
Shortcodes
If you write in Markdown and find yourself frequently embedding your content with raw HTML, Hugo provides built-in shortcodes functionality. This is one of the most powerful features in Hugo and allows you to create your own Markdown extensions very quickly.
See Shortcodes for usage, particularly for the built-in shortcodes that ship with Hugo, and Shortcode Templating to learn how to build your own.
Code Blocks
Hugo supports GitHub-flavored markdown's use of triple back ticks, as well as provides a special highlight
shortcode, and syntax highlights those code blocks natively using Chroma. Users also have an option to use Pygments instead. See the Syntax Highlighting section for details.
Mmark
Mmark is a fork of BlackFriday and markdown superset that is well suited for writing IETF documentation. You can see examples of the syntax in the Mmark GitHub repository or the full syntax on Miek Gieben's website.
Use Mmark
As Hugo ships with Mmark, using the syntax is as easy as changing the extension of your content files from .md
to .mmark
.
In the event that you want to only use Mmark in specific files, you can also define the Mmark syntax in your content's front matter:
---
title: My Post
date: 2017-04-01
markup: mmark
---
{{% warning %}}
Thare are some features not available in Mmark; one example being that shortcodes are not translated when used in an included .mmark
file (#3131), and EXTENSION_ABBREVIATION
(#1970) and the aforementioned GFM todo lists (#2270) are not fully supported. Contributions are welcome.
{{% /warning %}}
MathJax with Hugo
MathJax is a JavaScript library that allows the display of mathematical expressions described via a LaTeX-style syntax in the HTML (or Markdown) source of a web page. As it is a pure a JavaScript library, getting it to work within Hugo is fairly straightforward, but does have some oddities that will be discussed here.
This is not an introduction into actually using MathJax to render typeset mathematics on your website. Instead, this page is a collection of tips and hints for one way to get MathJax working on a website built with Hugo.
Enable MathJax
The first step is to enable MathJax on pages that you would like to have typeset math. There are multiple ways to do this (adventurous readers can consult the Loading and Configuring section of the MathJax documentation for additional methods of including MathJax), but the easiest way is to use the secure MathJax CDN by include a <script>
tag for the officially recommended secure CDN (cdn.js.com):
{{< code file="add-mathjax-to-page.html" >}}
{{< /code >}}
One way to ensure that this code is included in all pages is to put it in one of the templates that live in the layouts/partials/
directory. For example, I have included this in the bottom of my template footer.html
because I know that the footer will be included in every page of my website.
Options and Features
MathJax is a stable open-source library with many features. I encourage the interested reader to view the MathJax Documentation, specifically the sections on Basic Usage and MathJax Configuration Options.
Issues with Markdown
{{% note %}}
The following issues with Markdown assume you are using .md
for content and BlackFriday for parsing. Using Mmark as your content format will obviate the need for the following workarounds.
When using Mmark with MathJax, use displayMath: [['$$','$$'], ['\\[','\\]']]
. See the Mmark README.md
for more information. In addition to MathJax, Mmark has been shown to work well with KaTeX. See this related blog post from a Hugo user.
{{% /note %}}
After enabling MathJax, any math entered between proper markers (see the MathJax documentation) will be processed and typeset in the web page. One issue that comes up, however, with Markdown is that the underscore character (_
) is interpreted by Markdown as a way to wrap text in emph
blocks while LaTeX (MathJax) interprets the underscore as a way to create a subscript. This "double speak" of the underscore can result in some unexpected and unwanted behavior.
Solution
There are multiple ways to remedy this problem. One solution is to simply escape each underscore in your math code by entering \_
instead of _
. This can become quite tedious if the equations you are entering are full of subscripts.
Another option is to tell Markdown to treat the MathJax code as verbatim code and not process it. One way to do this is to wrap the math expression inside a <div>
</div>
block. Markdown would ignore these sections and they would get passed directly on to MathJax and processed correctly. This works great for display style mathematics, but for inline math expressions the line break induced by the <div>
is not acceptable. The syntax for instructing Markdown to treat inline text as verbatim is by wrapping it in backticks (`
). You might have noticed, however, that the text included in between backticks is rendered differently than standard text (on this site these are items highlighted in red). To get around this problem, we could create a new CSS entry that would apply standard styling to all inline verbatim text that includes MathJax code. Below I will show the HTML and CSS source that would accomplish this (note this solution was adapted from this blog post---all credit goes to the original author).
{{< code file="mathjax-markdown-solution.html" >}}
{{< /code >}}
As before, this content should be included in the HTML source of each page that will be using MathJax. The next code snippet contains the CSS that is used to have verbatim MathJax blocks render with the same font style as the body of the page.
{{< code file="mathjax-style.css" >}} code.has-jax { font: inherit; font-size: 100%; background: inherit; border: inherit; color: #515151; } {{< /code >}}
In the CSS snippet, notice the line color: #515151;
. #515151
is the value assigned to the color
attribute of the body
class in my CSS. In order for the equations to fit in with the body of a web page, this value should be the same as the color of the body.
Usage
With this setup, everything is in place for a natural usage of MathJax on pages generated using Hugo. In order to include inline mathematics, just put LaTeX code in between `$ TeX Code $`
or `\( TeX Code \)`
. To include display style mathematics, just put LaTeX code in between <div>$$TeX Code$$</div>
. All the math will be properly typeset and displayed within your Hugo generated web page!
Additional Formats Through External Helpers
Hugo has a new concept called external helpers. It means that you can write your content using Asciidoc, reStructuredText, or pandoc. If you have files with associated extensions, Hugo will call external commands to generate the content. (See the Hugo source code for external helpers.)
For example, for Asciidoc files, Hugo will try to call the asciidoctor
or asciidoc
command. This means that you will have to install the associated tool on your machine to be able to use these formats. (See the Asciidoctor docs for installation instructions).
To use these formats, just use the standard extension and the front matter exactly as you would do with natively supported .md
files.
Hugo passes reasonable default arguments to these external helpers by default:
asciidoc
:--no-header-footer --safe -
asciidoctor
:--no-header-footer --safe --trace -
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 %}}
Learn Markdown
Markdown syntax is simple enough to learn in a single sitting. The following are excellent resources to get you up and running: