Markdown is a lightweight markup language that was designed to be easy for humans to read and write. For example, the Markdown markup for a list can look like this list of colors of a rainbow🌈:
* Red
* Orange
* Yellow
* Green
* Blue
* Indigo
* Violet
This is simpler than the HTML markup for this list, which can look like this:
<ul>
<li>Red</li>
<li>Orange</li>
<li>Yellow</li>
<li>Green</li>
<li>Blue</li>
<li>Indigo</li>
<li>Violet</li>
</ul>
Details about the Markdown markup for unordered lists – and a lot more – are in the ordinary and extraordinary features sections below.
Because Markdown is so lightweight, a lot of extended flavors have been created since its inception in 2004 (~20 years ago). For an overview of Markdown’s history, flavors, and more, see wikipedia.org/wiki/Markdown.
This article is written in Goldmark-flavored Markdown and rendered to HTML by the static site generator Hugo. To learn about Hugo’s markup settings, see:
Here is the part of Infinite Ink’s Hugo config file that is relevant to rendering Goldmark-flavored Markdown:
markup:
goldmark:
extensions:
cjk:
eastAsianLineBreaks: false
eastAsianLineBreaksStyle: simple
enable: false
escapedSpace: false
definitionList: true
footnote: true
linkify: true
linkifyProtocol: https
strikethrough: true
table: true
taskList: true
typographer:
apostrophe: '’'
disable: false
ellipsis: '…'
emDash: '—'
enDash: '–'
leftAngleQuote: '«'
leftDoubleQuote: '“'
leftSingleQuote: '‘'
rightAngleQuote: '»'
rightDoubleQuote: '”'
rightSingleQuote: '’'
parser:
attribute:
block: true # default is false
title: true
autoHeadingID: true
autoHeadingIDType: github
wrapStandAloneImageWithinParagraph: false # default is true
renderer:
hardWraps: false
unsafe: true # default is false
xhtml: false
highlight:
anchorLineNos: false
codeFences: true
guessSyntax: false
hl_Lines:
hl_inline: false
lineAnchors:
lineNoStart: 1
lineNos: false
lineNumbersInTable: true
noClasses: true
noHl: false
style: manni # default is monokai
tabWidth: 4
All but the
four
emphasized
lines
are Hugo’s
default Markdown settings.
Thanks to
unsafe: true
<br>
)
in Markdown
through to the
markdownified1
destination
file.
💡 | If you control your
Hugo content files, it’s safe to specify
|
The “Markdown ordinary features” and “Markdown extraordinary features” sections below were created by @jonschlinkert and forked by Infinite Ink. The original source is at gist.github.com/jonschlinkert/5854601. Thank you @jonschlinkert!3
The following Markdown features are defined by the CommonMark standard, and are generally supported by all markdown parsers and editors.
Headings from h1
through h6
are constructed with a #
for each level:
# h1 Heading
## h2 Heading
### h3 Heading
#### h4 Heading
##### h5 Heading
###### h6 Heading
Renders to:
And this HTML:
<h1>h1 Heading</h1>
<h2>h2 Heading</h2>
<h3>h3 Heading</h3>
<h4>h4 Heading</h4>
<h5>h5 Heading</h5>
<h6>h6 Heading</h6>
A note about “Setext” Headings
Note that this document only describes ATX headings, as it is the preferred syntax for writing headings. However, the CommonMark specification also describes Setext headings, a heading format that is denoted by a line of dashes or equal signs following the heading. It’s recommended by the author of this guide that you use only ATX headings, as they are easier to read and write in text editors.
Body copy written as
normal plain text
will be wrapped with <p></p>
tags in the rendered HTML.
So this:
Lorem ipsum dolor sit amet, graecis denique ei vel, at duo primis mandamus. Et legere ocurreret pri, animal tacimates complectitur ad cum. Cu eum inermis inimicus efficiendi. Labore officiis his ex, soluta officiis concludaturque ei qui, vide sensibus vim ad.
Renders to this HTML:
<p>Lorem ipsum dolor sit amet, graecis denique ei vel, at duo primis mandamus. Et legere ocurreret pri, animal tacimates complectitur ad cum. Cu eum inermis inimicus efficiendi. Labore officiis his ex, soluta officiis concludaturque ei qui, vide sensibus vim ad.</p>
You can use multiple consecutive newline
characters to create extra spacing between sections in a markdown document. However, if you need to
ensure that extra newlines are not collapsed, you can use as many HTML <br>
elements as you
want.4
The HTML <hr>
element is for creating a “thematic break” between paragraph-level elements. In markdown, you can
use the
following for this purpose:
___
: three consecutive underscores---
: three consecutive dashes***
: three consecutive asterisksRenders to:
For emphasizing a snippet of text with a heavier font-weight.
The following snippet of text is rendered as bold text.
**rendered as bold text**
renders to:
rendered as bold text
and this HTML
<strong>rendered as bold text</strong>
For emphasizing a snippet of text with italics.
The following snippet of text is rendered as italicized text.
_rendered as italicized text_
renders to:
rendered as italicized text
and this HTML:
<em>rendered as italicized text</em>
Used for defining a section of quoted text from another source, within your document.
To create a blockquote, use >
before any text you want to quote.
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante
Renders to:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
And the generated HTML from a markdown parser might look something like this:
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
</blockquote>
Blockquotes can also be nested:
> Donec massa lacus, ultricies a ullamcorper in, fermentum sed augue.
Nunc augue augue, aliquam non hendrerit ac, commodo vel nisi.
>> Sed adipiscing elit vitae augue consectetur a gravida nunc vehicula. Donec auctor
odio non est accumsan facilisis. Aliquam id turpis in dolor tincidunt mollis ac eu diam.
>>> Donec massa lacus, ultricies a ullamcorper in, fermentum sed augue.
Nunc augue augue, aliquam non hendrerit ac, commodo vel nisi.
Renders to:
Donec massa lacus, ultricies a ullamcorper in, fermentum sed augue. Nunc augue augue, aliquam non hendrerit ac, commodo vel nisi.
Sed adipiscing elit vitae augue consectetur a gravida nunc vehicula. Donec auctor odio non est accumsan facilisis. Aliquam id turpis in dolor tincidunt mollis ac eu diam.
Donec massa lacus, ultricies a ullamcorper in, fermentum sed augue. Nunc augue augue, aliquam non hendrerit ac, commodo vel nisi.
A list of items in which the order of the items does not explicitly matter.
You may use any of the following symbols to denote bullets for each list item:
* valid bullet
- valid bullet
+ valid bullet
For example
+ Lorem ipsum dolor sit amet
+ Consectetur adipiscing elit
+ Integer molestie lorem at massa
+ Facilisis in pretium nisl aliquet
+ Nulla volutpat aliquam velit
- Phasellus iaculis neque
- Purus sodales ultricies
- Vestibulum laoreet porttitor sem
- Ac tristique libero volutpat at
+ Faucibus porta lacus fringilla vel
+ Aenean sit amet erat nunc
+ Eget porttitor lorem
Renders to:
And this HTML
<ul>
<li>Lorem ipsum dolor sit amet</li>
<li>Consectetur adipiscing elit</li>
<li>Integer molestie lorem at massa</li>
<li>Facilisis in pretium nisl aliquet</li>
<li>Nulla volutpat aliquam velit
<ul>
<li>Phasellus iaculis neque</li>
<li>Purus sodales ultricies</li>
<li>Vestibulum laoreet porttitor sem</li>
<li>Ac tristique libero volutpat at</li>
</ul>
</li>
<li>Faucibus porta lacus fringilla vel</li>
<li>Aenean sit amet erat nunc</li>
<li>Eget porttitor lorem</li>
</ul>
A list of items in which the order of items does explicitly matter.
1. Lorem ipsum dolor sit amet
2. Consectetur adipiscing elit
3. Integer molestie lorem at massa
4. Facilisis in pretium nisl aliquet
5. Nulla volutpat aliquam velit
6. Faucibus porta lacus fringilla vel
7. Aenean sit amet erat nunc
8. Eget porttitor lorem
Renders to:
And this HTML:
<ol>
<li>Lorem ipsum dolor sit amet</li>
<li>Consectetur adipiscing elit</li>
<li>Integer molestie lorem at massa</li>
<li>Facilisis in pretium nisl aliquet</li>
<li>Nulla volutpat aliquam velit</li>
<li>Faucibus porta lacus fringilla vel</li>
<li>Aenean sit amet erat nunc</li>
<li>Eget porttitor lorem</li>
</ol>
Sometimes lists change, and when they do it’s a pain to re-order all of the numbers. Markdown solves this problem by allowing you to simply use 1.
before each item in the list.
For example:
1. Lorem ipsum dolor sit amet
1. Consectetur adipiscing elit
1. Integer molestie lorem at massa
1. Facilisis in pretium nisl aliquet
1. Nulla volutpat aliquam velit
1. Faucibus porta lacus fringilla vel
1. Aenean sit amet erat nunc
1. Eget porttitor lorem
Automatically re-numbers the items and renders to:
Wrap inline snippets of code with a single backtick: `
.
For example, to show <div></div>
inline with other text, just wrap it in backticks.
For example, to show `<div></div>` inline with other text, just wrap it in backticks.
Three consecutive backticks, referred to as “code fences”, are used to denote multiple lines of code: ```
.
For example, this:
```html Example text here... ```
Appears like this when viewed in a browser:
Example text here...
And renders to something like this in HTML:
<pre>
<p>Example text here...</p>
</pre>
You may also indent several lines of code by at least four spaces, but this is not recommended as it is harder to read, harder to maintain, and doesn’t support syntax highlighting.
Example:
// Some comments
line 1 of code
line 2 of code
line 3 of code
// Some comments
line 1 of code
line 2 of code
line 3 of code
Various markdown parsers, such as
remarkable,
support syntax highlighting with fenced code blocks. To activate the correct styling for the language inside the code block, simply add the file extension of the language you want to use directly after the first code “fence”: ```js
, and syntax highlighting will automatically be applied in the rendered HTML (if supported by the parser). For example, to apply syntax highlighting to JavaScript code:
```js grunt.initConfig({ assemble: { options: { assets: 'docs/assets', data: 'src/data/*.{json,yml}', helpers: 'src/custom-helpers.js', partials: ['src/partials/**/*.{hbs,md}'] }, pages: { options: { layout: 'default.hbs' }, files: { './': ['src/templates/pages/index.hbs'] } } } }); ```
Which renders to:
grunt.initConfig({
assemble: {
options: {
assets: 'docs/assets',
data: 'src/data/*.{json,yml}',
helpers: 'src/custom-helpers.js',
partials: ['src/partials/**/*.{hbs,md}']
},
pages: {
options: {
layout: 'default.hbs'
},
files: {
'./': ['src/templates/pages/index.hbs']
}
}
}
});
And the following complicated HTML is an example of what might be generated by the markdown parser, when syntax highlighting is applied by a library like highlight.js:
<div class="highlight"><pre><span class="nx">grunt</span><span class="p">.</span><span class="nx">initConfig</span><span class="p">({</span>
<span class="nx">assemble</span><span class="o">:</span> <span class="p">{</span>
<span class="nx">options</span><span class="o">:</span> <span class="p">{</span>
<span class="nx">assets</span><span class="o">:</span> <span class="s1">'docs/assets'</span><span class="p">,</span>
<span class="nx">data</span><span class="o">:</span> <span class="s1">'src/data/*.{json,yml}'</span><span class="p">,</span>
<span class="nx">helpers</span><span class="o">:</span> <span class="s1">'src/custom-helpers.js'</span><span class="p">,</span>
<span class="nx">partials</span><span class="o">:</span> <span class="p">[</span><span class="s1">'src/partials/**/*.{hbs,md}'</span><span class="p">]</span>
<span class="p">},</span>
<span class="nx">pages</span><span class="o">:</span> <span class="p">{</span>
<span class="nx">options</span><span class="o">:</span> <span class="p">{</span>
<span class="nx">layout</span><span class="o">:</span> <span class="s1">'default.hbs'</span>
<span class="p">},</span>
<span class="nx">files</span><span class="o">:</span> <span class="p">{</span>
<span class="s1">'./'</span><span class="o">:</span> <span class="p">[</span><span class="s1">'src/templates/pages/index.hbs'</span><span class="p">]</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">});</span>
</pre></div>
Autolinks are absolute URIs and email addresses inside <
and >
. They are parsed as links, where the URI or email address itself is used as the link’s label.
<http://foo.bar.baz>
Renders to:
URIs or email addresses that are not wrapped in angle brackets are not recognized as valid autolinks by some markdown parsers.
[Assemble](http://assemble.io)
Renders to (hover over the link, there is no tooltip):
HTML:
<a href="http://assemble.io">Assemble</a>
[Upstage](https://github.com/upstage/ "Visit Upstage!")
Renders to (hover over the link, there should be a tooltip):
HTML:
<a href="https://github.com/upstage/" title="Visit Upstage!">Upstage</a>
Named anchors enable you to jump to the specified anchor point on the same page. For example, each of these chapters:
# Table of Contents
* [Chapter 1](#chapter-1)
* [Chapter 2](#chapter-2)
* [Chapter 3](#chapter-3)
will jump to these sections:
## Chapter 1 <a name="chapter-1"></a>
Content for chapter one.
## Chapter 2 <a name="chapter-2"></a>
Content for chapter one.
## Chapter 3 <a name="chapter-3"></a>
Content for chapter one.
Anchor placement
Note that placement of achors is arbitrary, you can put them anywhere you want, not just in headings. This makes adding cross-references easy when writing markdown.
Images have a similar syntax to links but include a preceding exclamation point.

or

Like links, Images also have a footnote style syntax
![Alt text][id]
With a reference later in the document defining the URL location:
[id]: https://octodex.github.com/images/dojocat.jpg "The Dojocat"
Any text between <
and >
that looks like an HTML tag will be parsed as a raw HTML tag and rendered to HTML without
escaping.4
(Note that no attempt is made by the markdown parser to validate your HTML.)
Example:
**Visit <a href="https://github.com/jonschlinkert">Jon Schlinkert's GitHub Profile</a>.**
Renders to:
Visit Jon Schlinkert’s GitHub Profile.
Any character may be escaped using a single backslash.
Example:
\*this is not italic*
Renders to:
*this is not italic*
To specify a literal backslash use…
\\
which renders to
\
Example:
\\[\\LaTeX\\]
Renders to the following in the HTML that is generated from the Markdown:
\[\LaTeX\]
If the appropriate MathJax scripts are called from a web page (as they are on this page), the above will be rendered in a web browser as the LaTeX logo:
\[\LaTeX\]
assuming that 1) you are connected to the internet and 2) JavaScript is enabled in your web browser.
The following markdown features are not defined by the CommonMark specification, but they are commonly supported by markdown parsers and editors, as well as sites like Codeberg, GitHub, and GitLab.
In GFM5 you can do strikethroughs.
~~Strike through this text.~~
Which renders to:
Strike through this text.
- [ ] Lorem ipsum dolor sit amet
- [ ] Consectetur adipiscing elit
- [ ] Integer molestie lorem at massa
Renders to:
Links in todo lists
- [ ] [foo](#bar)
- [ ] [baz](#qux)
- [ ] [fez](#faz)
Renders to:
Tables are created by adding pipes as dividers between each cell, and by adding a line of dashes (also separated by bars) beneath the header (this line of dashes is required).
Example:
| Option | Description |
| ------ | ----------- |
| data | path to data files to supply the data that will be passed into templates. |
| engine | engine to be used for processing templates. Handlebars is the default. |
| ext | extension to be used for dest files. |
Renders to:
Option | Description |
---|---|
data | path to data files to supply the data that will be passed into templates. |
engine | engine to be used for processing templates. Handlebars is the default. |
ext | extension to be used for dest files. |
And this HTML:
<table>
<tr>
<th>Option</th>
<th>Description</th>
</tr>
<tr>
<td>data</td>
<td>path to data files to supply the data that will be passed into templates.</td>
</tr>
<tr>
<td>engine</td>
<td>engine to be used for processing templates. Handlebars is the default.</td>
</tr>
<tr>
<td>ext</td>
<td>extension to be used for dest files.</td>
</tr>
</table>
Center text in a column
To center the text in a column, add a colon to the left and right of the dashes in the row beneath a header.
| Option | Description |
| :----: | :---------: |
| data | path to data files to supply the data that will be passed into templates. |
| engine | engine to be used for processing templates. Handlebars is the default. |
| ext | extension to be used for dest files. |
Renders to:
Option | Description |
---|---|
data | path to data files to supply the data that will be passed into templates. |
engine | engine to be used for processing templates. Handlebars is the default. |
ext | extension to be used for dest files. |
Right-align the text in a column
To right-align the text in a column, add a colon to the right of the dashes in the row beneath a header.
| Option | Description |
| -----: | ----------: |
| data | path to data files to supply the data that will be passed into templates. |
| engine | engine to be used for processing templates. Handlebars is the default. |
| ext | extension to be used for dest files. |
Renders to:
Option | Description |
---|---|
data | path to data files to supply the data that will be passed into templates. |
engine | engine to be used for processing templates. Handlebars is the default. |
ext | extension to be used for dest files. |
Markdown footnotes are not officially defined by the CommonMark specification, However, the feature is supported by some markdown parsers, and it’s very useful when available.
Markdown footnotes are referenced
by an opening square bracket, followed by a caret, followed by a
number (or an alphanumeric string)
and a closing square bracket, for example [^1]
.
This is some text[^1] with a footnote reference link.
The accompanying text for the footnote can be added elsewhere in the document using the following syntax:
[^1]: This is a by-reference footnote
When rendered to HTML, footnotes are “stacked” by the markdown parser at the bottom of the file, in the order in which the footnotes were defined.
Some (not all)6 Markdown parsers that support by-reference footnotes also support inline footnotes, but be aware that different Markdown parsers use different syntax for inline footnotes. For example, Blackfriday, Mmark, Pandoc Markdown, and PHP Markdown Extra use this syntax:
some text^[This is an inline footnote]
While old versions of remarkable used this syntax:
some text[^2 "This is an inline footnote"]
Some Markdown parsers support nested footnotes (footnotes within footnotes).🪆 For example, in footnote #1 below there is a link to another footnote.
Some Markdown parsers support specifying CSS style attributes. For example, if you use Hugo v0.81.0+ and this Markdown config (discussed above):
markup:
goldmark:
parser:
attribute:
block: true # default is false
…then you can style lists, paragraphs and more using syntax similar to the syntax in the examples below.
* salmon
* trout
{.fishbullets}
Renders as:
And this HTML:
<ul class="fishbullets">
<li>salmon</li>
<li>trout</li>
</ul>
This paragraph is styled with the Yozakura font.
To learn about this free font, see
[brushfonts.com](http://brushfonts.com/en/index.html).
{.iifont}
Renders as:
This paragraph is styled with the Yozakura font. To learn about this free font, see brushfonts.com.
And this HTML:
<p class="iifont">This paragraph is styled with the Yozakura font.
To learn about this free font, see
<a href="http://brushfonts.com/en/index.html">brushfonts.com</a>.</p>
To learn about using style attributes in Markdown, see:
For more about Markdown, see Infinite Ink’s…
To me, this is confusing terminology (because my first thought was that “markdownify” meant convert to Markdown.)🤔 ↩︎
The sections titled “Markdown ordinary features” and “Markdown extraordinary features” were forked from the “Standard features” and “Non-standard features” sections of the Markdown Cheatsheet at gist.github.com/jonschlinkert/5854601. Thank you @jonschlinkert and everyone who contributes to this open-source cheatsheet. ↩︎
If you want to use <br>
or any other raw HTML
in
Goldmark-flavored Markdown
in Hugo,
see
section
14.2. markup
in Infinite Ink’s
TGIH: Themeless & Gitless Introduction to the Hugo SSG (a Hugo tutorial👩🏫). ↩︎ ↩︎
The acronym GFM usually means GitHub-flavored Markdown. To learn about GFM, see github.com’s Mastering Markdown, Writing on GitHub, and GitHub Flavored Markdown Spec. ↩︎
Hugo’s default Markdown parser,
Goldmark,
supports by-reference footnotes but
does not support
inline footnotes.
Hugo’s alternate Markdown parser,
Pandoc,
supports
inline footnotes
and
@nm@mathstodon.xyz
or
#InfiniteInk
in it.