Markdown Syntax Guide

Table of Contents

For a quick cheatsheet, check out https://simplemde.com/markdown-guide ↗ .


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.

H2

H3

H4

H5
H6

Paragraph

Xerum, quo qui aut unt expliquam qui dolut labo. Aque venitatiusda cum, voluptionse latur sitiae dolessi aut parist aut dollo enim qui voluptate ma dolestendit peritin re plis aut quas inctum laceat est volestemque commosa as cus endigna tectur, offic to cor sequas etum rerum idem sintibus eiur? Quianimin porecus evelectur, cum que nis nust voloribus ratem aut omnimi, sitatur? Quiatem. Nam, omnis sum am facea corem alique molestrunt et eos evelece arcillit ut aut eos eos nus, sin conecerem erum fuga. Ri oditatquam, ad quibus unda veliamenimin cusam et facea ipsamus es exerum sitate dolores editium rerore eost, temped molorro ratiae volorro te reribus dolorer sperchicium faceata tiustia prat.

Itatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sapicia is sinveli squiatum, core et que aut hariosam ex eat.

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.

Blockquote without attribution

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

Blockquote with attribution

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

Tables

Tables aren’t part of the core Markdown spec, but Hugo supports supports them out-of-the-box.

NameAge
Bob27
Alice23

Inline Markdown within tables

ItalicsBoldCode
italicsboldcode

Code Blocks

Code block with backticks

 1<!doctype html>
 2<html lang="en">
 3<head>
 4  <meta charset="utf-8">
 5  <title>Example HTML5 Document</title>
 6</head>
 7<body>
 8  <p>Test</p>
 9</body>
10</html>

Code block indented with four spaces

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Example HTML5 Document</title>
</head>
<body>
  <p>Test</p>
</body>
</html>

Code block with Hugo’s internal highlight shortcode

 1<!doctype html>
 2<html lang="en">
 3<head>
 4  <meta charset="utf-8">
 5  <title>Example HTML5 Document</title>
 6</head>
 7<body>
 8  <p>Test</p>
 9</body>
10</html>
1declare a=1
2echo "$a"
3exit
 1#!/usr/bin/env bash
 2
 3host=$(grep -E '^Host ' ~/.ssh/config | awk '{print $2}' | grep -v '[*?]' |
 4	rofi -dmenu -p "SSH" -kb-custom-1 "Alt+Return" -mesg "Alt+Enter: New kitty window")
 5ret=$?
 6
 7if [ -n "$host" ]; then
 8	case $ret in
 9	0) # Enter → tmux new-window
10		tmux new-window "ssh $host"
11		;;
12	10) # Alt+Enter → new kitty window
13		kitty ssh "$host" &
14		;;
15	esac
16fi
main.go
 1package main
 2
 3import (
 4	"database/sql"
 5	"encoding/json"
 6	"fmt"
 7	"html/template"
 8	"io/ioutil"
 9	"log"
10	"net/http"
11	"net/url"
12	"os"
13	"strings"
14	"time"
15
16	"github.com/gin-gonic/gin"
17	_ "github.com/mattn/go-sqlite3"
18)
19
20const (
21	baseURL = "http://www.omdbapi.com/"
22)
23
24var (
25	apiKey = os.Getenv("API_KEY")
26	tmpl   = template.Must(template.ParseFiles("templates/index.html"))
27)
28
29type Movie struct {
30	ID     int
31	Hash   string
32	Title  string
33	Dt     string
34	Cat    string
35	Size   int64
36	ExtID  sql.NullString
37	IMDB   sql.NullString
38}
39
40type SearchResult struct {
41	Search       []struct{ ImdbID string `json:"imdbID"` } `json:"Search"`
42	TotalResults string                                     `json:"totalResults"`
43	Response     string                                     `json:"Response"`
44}
45
46func (m *Movie) SizeReadable() string {
47	if m.Size >= 1<<30 {
48		return fmt.Sprintf("%.2f GB", float64(m.Size)/(1<<30))
49	}
50	return fmt.Sprintf("%.2f MB", float64(m.Size)/(1<<20))
51}
52
53func (m *Movie) FormattedDate() string {
54	t, err := time.Parse("2006-01-02 15:04:05", m.Dt)
55	if err != nil {
56		return m.Dt
57	}
58	return t.Format("02 Jan 2006 - 15:04:05")
59}
60
61func getIMDbID(movieName string) (string, error) {
62	url := fmt.Sprintf("%s?apikey=%s&s=%s", baseURL, apiKey, url.QueryEscape(movieName))
63	resp, err := http.Get(url)
64	if err != nil {
65		return "", err
66	}
67	defer resp.Body.Close()
68
69	body, err := ioutil.ReadAll(resp.Body)
70	if err != nil {
71		return "", err
72	}
73
74	var result SearchResult
75	if err := json.Unmarshal(body, &result); err != nil {
76		return "", err
77	}
78
79	if len(result.Search) == 0 {
80		return "", fmt.Errorf("no results found for '%s'", movieName)
81	}
82
83	return result.Search[0].ImdbID, nil
84}
 1import subprocess
 2import time
 3
 4import typer
 5from rich.progress import track
 6from typing_extensions import Annotated
 7
 8app = typer.Typer(no_args_is_help=True)
 9
10
11@app.command()
12def create(
13    name: Annotated[str, typer.Option(help="Name of the Debian Virtual Machine")],
14    ram: Annotated[
15        int, typer.Option(help="Amount of RAM in Megabytes, like 1024 or 2048")
16    ],
17    vcpu: Annotated[int, typer.Option(help="Number of virtual CPU cores, like 1 or 2")],
18    port: Annotated[
19        int, typer.Option(help="Host port to connect with. Maps PORT to :22 internally")
20    ],
21):
22    user_data_path = f"/home/dpi0/projects/kubernetes/the-hard-way/kvm-provisioning/{name}/user-data.yml"
23    cidata_iso_path = f"/var/lib/libvirt/images/{name}-cidata.iso"
24    qcow2_path = f"/var/lib/libvirt/images/{name}.qcow2"
25    template_path = (
26        "/var/lib/libvirt/images/templates/debian-12-genericcloud-amd64.qcow2"
27    )
28    qemu_log = f"/var/log/qemu-{name}.log"
29
30    commands = [
31        ["sudo", "cloud-localds", cidata_iso_path, user_data_path],
32        [
33            "sudo",
34            "qemu-img",
35            "create",
36            "-f",
37            "qcow2",
38            "-F",
39            "qcow2",
40            "-b",
41            template_path,
42            qcow2_path,
43            "10G",
44        ],
45        [
46            "sudo",
47            "qemu-system-x86_64",
48            "-enable-kvm",
49            "-m",
50            str(ram),
51            "-smp",
52            str(vcpu),
53            "-drive",
54            f"file={qcow2_path},format=qcow2",
55            "-drive",
56            f"file={cidata_iso_path},format=raw",
57            "-netdev",
58            f"user,id=net0,hostfwd=tcp::{port}-:22",
59            "-device",
60            "virtio-net-pci,netdev=net0",
61            "-display",
62            "none",
63            "-daemonize",
64            "-serial",
65            f"file:{qemu_log}",
66        ],
67    ]
68
69    for cmd in commands:
70        typer.echo(f"Running: {' '.join(cmd)}")
71        subprocess.run(cmd, check=True)
72
73    typer.echo("Waiting for VM to boot...")
74    for _ in track(range(30), description="🟢 Booting VM..."):
75        time.sleep(1)
76
77
78@app.callback()
79def callback():
80    """Debian VM provisioner with QEMU/KVM and cloud-init"""
81    pass
82
83
84if __name__ == "__main__":
85    app()
1$var = ["bob", "sam"];
2foreach ($var as $name) {
3    echo $var;
4}
main.go
1package main
2
3import "fmt"
4
5func main() {
6    fmt.Println("Hello, Hugo!")
7}
index.html
 1<!doctype html>
 2<html lang="en">
 3<head>
 4  <meta charset="utf-8">
 5  <title>Example HTML5 Document</title>
 6</head>
 7<body>
 8  <p>Test</p>
 9</body>
10</html>

List Types

Ordered List

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

Unordered List

Nested list

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.


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

#Markdown #Syntax

Did this post help you?

Support Me On Ko-Fi