Get Down With Markdown

• 5 min read • Share

Most developers will encounter Markdown files at some stage of their careers, via repository platforms such as GitHub or Bitbucket. Markdown files use the .md file extension and will contain specific syntax used to construct the file. Many content management systems and frameworks support markdown out the box, so to start using it is as simple as creating a file and adding its content.

Markdown files are extremely powerful because it allows the creator the ability to easily construct beautiful and semantic markup without having to build it with code. They are often used inside git repositories as documentation but have also grown to be extremely popular on blogging platforms. I personally store my posts on GitHub which Hugo then turns into semantic HTML.

In this tutorial, I will cover some basic syntax used inside Markdown files which will allow you to start creating beautifully structured content.

Headings:

Headings will be represented by adding a # symbol before the title. The number of # symbols signifies the order of importance, so by adding a single # it will represent a <h1> tag. Adding additional # symbols will decrease the order of importance with the number of symbols indicating the appropriate <h1> to <h6> tag.

1# Heading 1 <h1>
2## Heading 2 <h2>
3### Heading 3 <h3>
4#### Heading 4 <h4>
5##### Heading 5 <h5>
6###### Heading 6 <h6>

Paragraphs:

There is no specific syntax used when writing paragraphs in markdown syntax. Paragraphs can be created by adding one or more blank lines:

1I am a paragraph.
2 
3I am another paragraph.

When adding headings and paragraphs, make sure they are all separated by a new line and are not on top of each other.

Line breaks:

Line breaks are similar to paragraphs except instead of a single blank line you will add two blank lines to signify a line break.

1I am a paragraph with a line break below me.
2 
3I am a paragraph with a line break above me.

Bold Text:

As we go further into this tutorial, you will find that there are many ways to achieve the same result. For example, bold text can be added to a document in the following ways:

**Bold text** will render Bold text

__Bold text__ will render Bold text

Italic text:

The syntax for italic text is similar to that of bold text. A single asterisk or underscore will be used on either side of the text or phrase.

*Italic text* will render: Italic text

_Italic text_ will render: Italic text

Lists:

Lists have varying syntax.

To create ordered lists, simply add items with numbers followed by a period. Each list item will need to be on a new line.

11. Ordered list item #1
22. Ordered list item #2
33. Ordered list item #3

They do not need to be in numerical order:

11. Ordered list item #1
23. Ordered list item #3
32. Ordered list item #2

You may also nest lists:

11. Ordered list item #1
22. Ordered list item #2
33. Ordered list item #3
4 1. Ordered nested list item #1
5 2. Ordered nested list item #2

To create an unordered list, simply add either a dash (-), asterisk (*), or plus signs (+) in front of your line items.

1- Unordered list item #1
2- Unordered list item #2
3- Unordered list item #3

Much like the ordered list, the same principle applies when nesting unordered lists.

1- Unordered list item #1
2- Unordered list item #2
3- Unordered list item #3
4 - Unordered nested list item #1
5 - Unordered nested list item #2
6 - Unordered nested list item #3

Links:

To create a link, enclose the text you wish to link with square brackets followed by the link in parentheses.

1[example.com](https://example.com/)

example.com

If you would like to add a title to the link, you would add the following:

1[example.com](https://example.com/ "Link title")

example.com

Links can also be created by adding a chevron on either side of the link:

1<https://example.com>

https://example.com

Using the above syntax is especially useful for email addresses:

1[Email us!](mailto:email@example.com)

Email us!

Images:

Images have a similar syntax to links, except they have an exclamation mark in front of the square brackets, followed by the alt text inside the square brackets and the path to the image in parentheses.

1![Alt text](/assets/images/image-1.jpg)

Alt text

Much like links a title can also be added to an image by adding the following:

1![I am the alt text](/assets/images/image-2.jpg "Image title")

I am the alt text

Block Quotes:

A blockquote can be created by adding a right-facing chevron > in front of a paragraph.

1> I am a blockquote

Using this syntax will render the following:

I am a blockquote

Code:

Code blocks can be added to markdown files by enclosing the word, phrase or code with backticks. (``)

1`A code block using backticks`

Alternatively you may create code blocks by indenting by at least four spaces or with one tab:

1A code block created using four spaces or one tab.

Horizontal rules:

There are a number of ways to add a horizontal rule to a document by either adding three or more asterisks (***), dashes or underscores:

1---
2 
3_________________
4 
5***

Any of the above will render:


HTML:

Some Markdown applications or frameworks allow you to insert HTML tags into the file. This is useful if you would like to use certain HTML tags instead of Markdown syntax. Using this approach it is much easier to change the attributes of an element.

1I am using regular **bold** syntax with an HTML link <a href="#" class="text-blue-100">Link</a>

Conclusion:

As you can see Markdown is extremely powerful and user-friendly, it has many benefits and provides creators with an easy way to create beautifully structured content. It is a huge time saver and allows you to focus on what truly matters most, your content.

Join my mailing list.

Receive my latest content by email. No spam, ever.