Markdown is a simple and easy-to-use formatting syntax that’s becoming increasingly standard across the web. Whether you’re a blogger, developer, or just someone who wants to quickly format text, Markdown (or .md for short) is a lightweight markup language that can help.
Hugo, a popular static site generator and the engine behind this blog, uses Markdown for writing content, and Markdown’s implementation is slightly different depending on the platform.
In this blog post, I’ve put together a Markdown cheatsheet with examples to cover Hugo’s flavour of Markdown, so you can easily format content for your Hugo website.
Headers
# Big Heading
## Small Heading
Big Heading
Small Heading
Lists
- dashes
- make bullets
* astersisks
* do too
1. numbers render
42. `<ol>` and `<li>` lists. And the number don't matter
- dashes
- make bullets
- astersisks
- do too
- numbers render
<ol>
and<li>
lists. And the number don’t matter.
Line Breaks
Single line breaks
are ignored
If you don't want the single line break to be ignored\
Use a `\` at the end of the line!
Double carriage returns/line breaks create new paragraphs
Single line breaks are ignored
If you don’t want the single line break to be ignored
Use a \
at the end of the line!
Double carriage returns/line breaks create new paragraphs
Text Highlighting
**bold**
*italic*
_italic_
bold italic italic
Links, Images
[Link](https://en.wikipedia.org/wiki/Markdown).
![alt](https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Adult_Female_Plethodon_cinereus.jpg/320px-Adult_Female_Plethodon_cinereus.jpg "Image title")
![alt](../sugar-apple.jpg "Image title")
Link.
Tables
| Vertical Bars | Dashes | Colons |
| --- | :---: | ---: |
| for separating cells | for separating header from body (`<th>` vs `<tr>`) | table alignement |
outer bars are optional | must use a minimum of 3 `---` | must use `:` in conjunction with `---`
Vertical Bars | Dashes | Colons |
---|---|---|
for separating cells | for separating header from body (<th> vs <tr> ) | table alignement |
outer bars are optional | must use a minimum of 3 --- | must use : in conjunction with --- |
Quotes
> You can quote text using the ">" symbol
> For longer multi-line quotes that go on and on and on and on and on and on and on and on and on and on and on and on and on, you only need one ">" at the beginning to create a multiline quote.
You can quote text using the “>” symbol
For longer multi-line quotes that go on and on and on and on and on and on and on and on and on and on and on and on and on, you only need one “>” at the beginning to create a multiline quote.
Code
Code can be inserted using single backticks `
for short bits inline $i
, or by using triple backticks ```
for opening a code block, and then another triple for closing the block ```
# this is some generic pseudo-code
func Cow() {
var n=0
while (n < 2):
echo "Moo"
n++
}
Cow()
#wrapped in triple backticks
You can specify the language-specific syntax highlighting, for example ```md
for markup, ```js
for javascript:
function helloWorld() {
alert("Hello, World")
}
function helloWorld() {
print "Hello, World";
}
Misc
Horizontal rules:
---
or
___
HTML:
You <bold>can't</bold> use HTML directly within md in Hugo.
<div class='test' style="color:yellow">
It gets stripped out!
<div>
Unless you configure the goldmark renderer to “allow unsafe” (which I’ve done here).
To do so, add the following in your config.yml:
markup:
goldmark:
renderer:
unsafe: true
The you