Markdown Syntax Guide & Hugo Features

Roman: I’m mostly keeping this here as a reference for myself on how to write rich articles.

This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme.

Headings

The following HTML <h1><h6> elements represent six levels of section headings. <h1> is the highest section level while <h6> is the lowest.

H1

H2

H3

H4

H5
H6

Blockquotes

The blockquote element represents content that is quoted from another source, optionally with a citation which must be within a footer or cite element, and optionally with in-line changes such as annotations and abbreviations.

Without attribution

Tiam, ad mint andaepu dandae nostion secatur sequo quae. Note that you can use Markdown syntax within a blockquote.

With attribution

Don’t communicate by sharing memory, share memory by communicating.
Rob Pike1

Tables

Not a part of the core Markdown spec, but Hugo supports them out-of-the-box.

Name Age
Bob 27
Alice 23

Inline Markdown within tables

Italics Bold Code
italics bold code

Code Blocks

with backticks

<!doctype html>
<html lang="en">
<head>
  <title>Example HTML5 Document</title>
</head>
<body>
  <p>Test</p>
</body>
</html>

indented with four spaces

<!doctype html>
<html lang="en">
<head>
  <title>Example HTML5 Document</title>
</head>
<body>
  <p>Test</p>
</body>
</html>

Hugo’s internal highlight shortcode

<!doctype html>
<html lang="en">
<head>
  <title>Example HTML5 Document</title>
</head>
<body>
  <p>Test</p>
</body>
</html>

List Types

Ordered List

  1. First item
  2. Second item
  3. Third item

Unordered List

  • List item
  • Another item
  • And another item

Nested list

  • Fruit
    • Apple
  • Dairy
    • Milk

Other Elements — abbr, sub, sup, kbd, mark

GIF is a bitmap image format.

H2O

Xn + Yn = Zn

Press CTRL+ALT+Delete to end the session.

Most salamanders are nocturnal, and hunt for insects, worms, and other small creatures.

Math Type Setting

In this example we will be using KaTeX

  • Create a partial under /layouts/partials/math.html
  • Within this partial reference the Auto-render Extension or host these scripts locally.
  • Include the partial in your templates like so:
{{ if or .Params.math .Site.Params.math }}
{{ partial "math.html" . }}
{{ end }}
  • To enable KaTex globally set the parameter math to true in a project’s configuration
  • To enable KaTex on a per page basis include the parameter math: true in content files

Note: Use the online reference of Supported TeX Functions

Examples

Inline math: \(\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…\)

Block math: $$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$

Emoji

Emoji can be enabled in a Hugo project in a number of ways.

The emojify function can be called directly in templates or Inline Shortcodes.

To enable emoji globally, set enableEmoji to true in your site’s configuration and then you can type emoji shorthand codes directly in content files; e.g.

🙈 🙈 🙉 🙉 🙊 🙊


The Emoji cheat sheet is a useful reference for emoji shorthand codes.

Notes

The above steps enable Unicode Standard emoji characters and sequences in Hugo, however the rendering of these glyphs depends on the browser and the platform. To style the emoji you can either use a third party emoji font or a font stack; e.g.

.emoji {
  font-family: Apple Color Emoji, Segoe UI Emoji, NotoColorEmoji, Segoe UI Symbol, Android Emoji, EmojiSymbols;
}

Embedding Media

Youtube

Vimeo

Html

Images


  1. The above quote is excerpted from Rob Pike’s talk during Gopherfest, November 18, 2015. ↩︎

roman's lab

Technology and Engineering Blog