--- layout: handbook-page-toc title: "Markdown Guide" description: "Read through our Markdown kramdown Style Guide!" --- ## On this page {:.no_toc .hidden-md .hidden-lg} - TOC {:toc .hidden-md .hidden-lg} ## Markdown Style Guide for [about.GitLab.com] This website was generated by [Middleman], a blog-aware Static Site Generator ([SSG]) widely used by web developers. [Markup language] is part of the structure of any SSG. It is a system to write documents making them somehow syntactically distinguishable from text. [Lightweight markup languages] have a simplified and unobtrusive syntax, designed to be easily written within any text editor. That's what we use to write our content. The majority of SSGs use markdown engines for this purpose. Read through our blog post on [Modern Static Site Generators][ssgs-post] to understand how they work. For [about.GitLab.com] we use [kramdown], which is an advanced Markdown engine with a lot of interesting features that most of the other engines don't have, such as [inline attribute lists](https://kramdown.gettalong.org/syntax.html#inline-attribute-lists) (IALs), which enable easy styling beyond the standard Markdown options. If you never have written a single line in markdown markup, don't worry, it's easy to learn and even easier to use. You'll probably be surprised how handy it is once you get used to it. And you'll miss it whenever the tech you're using doesn't support markdown. In most of GitLab text areas you'll find markdown support. Not all of them run with kramdown, so the markup will not behave equally "GitLabwide". For **GitLab.com**, **GitLab CE** and **GitLab EE** text areas, the markdown engine is currently [CommonMarker]. Here you can find the [markdown style guide][gitlab-markdown] for them. This guide has been made to make it easier for everyone to use kramdown features and save a lot of time writing content for [about.GitLab.com], including handbook pages, website pages, blog posts and everything else within the project [www-GitLab-com]. There are different possible syntaxes for most of the markups described below, but this guide is to be considered the standard for [about.GitLab.com]. **Note:** this document is maintained by the [Technical Writing](../) Team. {:.note} ### Blog For our [Blog], everything in this guide can be applied. Read through the [Blog Style Guidelines] for further information. ---- ## Headings ```md ## Heading h2 ### Heading h3 #### Heading h4 ``` {::options parse_block_html="true" /}
**Output** {: .panel-heading}
## Heading h2 {:.no_toc style="margin-top:0"} ### Heading h3 {:.no_toc} #### Heading h4 {:.no_toc}
Notes: - We don't use `h1` headings, as they already are displayed on every page as its title, and we should not apply more than one `h1` per page. > _When you use a top level heading, or an

, you’re setting up a semantic relationship between that heading and the remainder of the content on a page, describing what it is about. If you then use a second

on the same page, you’re creating some potential confusion, because someone, or a search engine might see that as the ending of the semantic relationship between the content after the first

and the start of this new

._ [SEO Guide] - Always start with `h2` (`##`), and respect the order h2 → h3 → h4. Never skip the hierarchy level, such as h2 → h4. > _The six heading elements, H1 through H6, denote section headings. Although the order and occurrence of headings is not constrained by the HTML DTD, documents **should not skip levels** (for example, from H1 to H3), as converting such documents to other representations is often problematic._ [W3C] - Always leave a blank space between the hash `#` and the text next to it, otherwise it won't render properly. - For keeping the text clear and the markdown consistent, [jump a line](#jump-a-line) between any heading and its subsequent paragraph. ---- ## Paragraphs, breaks, and horizontal lines Regular paragraphs are obtained by just writing text lines. If you hit **enter** between two lines, both lines will be joined into a single paragraph, which is called [wrapping text][wrap]. But, if you leave a blank line between them, they will split into two paragraphs. It is a best practice to write each a paragraph on a single line. Don't put line breaks at the end of each sentence, and don't break up lines at a certain character limit. It is very difficult to review and edit copy with artificial lines breaks. In some Git tools, `diffs` in future MRs may be easier to understand with additional line breaks, however GitLab's web interface as well as many desktop Git tools feature substring change highlighting within lines and side-by-side or similar version comparison so there is no need for artificial line breaks. ### Wrapping Text We usually break the lines within paragraphs to facilitate reviews. Do not leave blank spaces after the last word of the line broken within a paragraph, unless you want it to be intentionally broken with a `
`. #### Regular paragraphs and automatic join ```md This text is a paragraph. This won't be another paragraph, it will join the line above it. This will be another paragraph, as it has a blank line above it. ```
**Output** {: .panel-heading}
This text is a paragraph. This won't be another paragraph, it will join the line above it. This will be another paragraph, as it has a blank line above it.
### Additional breaks In case you need an additional break (or some extra space between lines), you can simply use the HTML break tag `
`, leaving blank lines above and below it: ```html Text A
Text B ```
**Output** {: .panel-heading}
Text A
Text B
### Horizontal lines A sequence of three or more dashes will produce a horizontal line, but let's use always **4** as standard. Leave blank lines after and before it: ```html Text ---- Text ```
**Output** {: .panel-heading}
Text ---- Text
---- ## Emphasis: bold and italic To display bold or italic text, wrap it in stars or underlines: ```md This is **bold** and this is _italic_. ```
**Output** {: .panel-heading}
This is **bold** and this is _italic_.
---- ## Links There are a few different ways to display links with markdown markup, but to keep some standards, let's try to use the following options only. Important notes: {: #links-important-notes} - {: #note-meaningful-links} Don't take it as a restrictive rule, but [avoid using meaningless text for links][handbook-writing] as "this article" or "read here." The link text should be meaningful even if taken out of context; this makes the links more useful and accessible for people using screen readers. - {: #note-deadlinks-checker} Check for broken links: ### Inline Links We'd rather use inline links, such as `[Text to display](link)`, as they are easier to maintain. ### Relative links Use relative links when referring to links found on [about.gitlab.com](/). For example, a link to our blog handbook should look like this `/handbook/marketing/blog/` and **not** this `https://about.gitlab.com/handbook/marketing/blog/`. Remove everything from the `https` through `about.gitlab.com`, but retain the forward slash after `.com`. For links to GitLab.com or anywhere else you must use the entire link, including the `http:`. ### Mailto links If you're adding an email address to a page be sure to format your link with `mailto` to avoid creating broken links. For example, `[example@gitlab.com](mailto:example@gitlab.com)` ### Identifiers When there are **repeated** links across a single page, you can opt for using identifiers. Place the identifiers at the end of the paragraph (or the section), arranging them in alphabetical order. ```md [Text to display][identifier] will display a link. [Another text][another-identifier] will do the same. Hover the mouse over it to see the title. [This link] will do the same as well. It works as the identifier itself. [This link][] (same as above), has a second pair of empty brackets to indicate that the following parenthesis does not contain a link. works too. Must be used for explicit links. [another-identifier]: https://example.com "This example has a title" [identifier]: http://example1.com [this link]: http://example2.com ```
**Output** {: .panel-heading}
[Text to display][identifier] will display a link. [Another text][another-identifier] will do the same. Hover the mouse over it to see the title. [This link] will do the same as well. It works as the identifier itself. [This link][] (same as above), has a second pair of empty brackets to indicate that the following parenthesis does not contain a link. works too. Must be used for explicit links. [another-identifier]: https://example.com "This example has a title" [identifier]: http://example1.com [this link]: http://example2.com
Note: - {: #note-identifiers} Identifiers **are not** case sensitive. They can be single words as `[link]` or `[multiple words too]`. ---- ## Lists Both ordered and unordered lists are very straight-forward to produce. There are a few ways to produce the same results, but let's stick with the following, again, to maintain some standards. Always use **3** blank spaces to indent a nested list (to create sub items). Tip: don't leave blank lines **between the items**, unless you have a reason to do so. **Important:** always leave a blank line between the paragraph or heading and the subsequent list! If you don't, the list will not render. {:.alert .alert-info} ### Ordered lists Ordered lists are pretty easy to create. Couldn't be more intuitive: ```md Paragraph: 1. Item one 1. Sub item one 2. Sub item two 3. Sub item three 2. Item two ```
**Output** {: .panel-heading}
Paragraph: 1. Item one 1. Sub item one 2. Sub item two 3. Sub item three 2. Item two
To be practical and avoid errors on the numbers, use "1" for all the items. The markdown engine will output them in the correct order. ```md Paragraph: 1. Item one 1. Sub item one 1. Sub item two 1. Item two 1. Item three ```
**Output** {: .panel-heading}
Paragraph: 1. Item one 1. Sub item one 2. Sub item two 1. Item two 1. Item three
### Unordered lists Unordered lists are very easy to create too: ```md Paragraph: - Item 1 - Item 2 - Item 3 - Sub item 1 - Sub item 2 - Item 4 ```
**Output** {: .panel-heading}
Paragraph: - Item 1 - Item 2 - Item 3 - Sub item 1 - Sub item 2 - Item 4
### Split lists Let's say, for some reason, you want to split a list in different parts. To do that, use the markup `^` to indicate the end of a list and the beginning of the next: ```md - list one - item 1 - list one - item 2 - sub item 1 - sub item 2 - list one - item 3 ^ - list two - item A - list two - item B ^ - list three - item _i_ - list three - item _ii_ ```
**Output** {: .panel-heading}
- list one - item 1 - list one - item 2 - sub item 1 - sub item 2 - list one - item 3 ^ - list two - item A - list two - item B ^ - list three - item _i_ - list three - item _ii_
---- ## Images To insert images to your markdown file, use the markup `![ALT](/path/image.ext)`. The path can either be relative to the website, or a full URL for an external image. The supported formats are `.png`, `.jpg`, `.gif`. You might be able to use some `.svg` files too, depending on its structure. ```md ![Semantic description of image](/images/path/to/folder/image.png "Image Title") ``` You can also use an identifier, as we do for [links](#links): ```md ![Semantic description of image][identifier] ``` If you want to add a caption to your image, it's easily achieved with: ```md ![Semantic description of image](/images/path/to/folder/image.png)*My caption* ``` For clickable images, simply wrap the image markup into a [link markup](#links): ```md [![Semantic description of image](/images/path/to/folder/image.png "Hello World")*My caption*][about.gitlab.com] ```
**Output** {: .panel-heading}
[![Semantic description of image](/images/about-gitlab-com.png "Hello World")*My caption*][about.gitlab.com]
**Important notes:** {:#images-important-notes} - {: #image-shadow} Apply [shadow](#shadow) to your images! - {: #image-requirements} All images must be placed [under `/source/images/`][source-img], in an appropriate directory. Only screenshots and public domain images are permitted. - {: #image-alt-text} The text inside the square brackets is an image attribute called `ALT`, which stands for _alternative text_. [Including descriptive alt text][alt-text-best-practices] helps maintain accessibility for every visitor and should always be included with an image. When you add alt text be sure to describe the content and function of an image. In addition to the accessibility benefits, `ALT` is useful for SEO, and it is displayed when, for some reason, that image is not loaded by the browser. - {: #image-filename} For the same reasons, the image must contain a name related to it. Example: instead of `image-01.jpg`, name it `black-dog.jpg`, if it's a photo of a black dog. - {: #image-title} It's also recommendable adding an image title, as the "Hello World" exemplified above. ---- ## Diagrams There are two ways to insert diagrams via Markdown: 1. Mermaid 2. PlantUML ### Mermaid See the [examples in the GitLab docs](https://docs.gitlab.com/ee/user/markdown.html#mermaid) on how to use Mermaid. You can also use the [live mermaid editor](https://mermaid-js.github.io/mermaid-live-editor) to check your work! ### PlantUML You can use [PlantUML](http://plantuml.com/) in Markdown blocks. For example: ~~~ ```plantuml !define ICONURL https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/v2.1.0 skinparam defaultTextAlignment center !include ICONURL/common.puml !include ICONURL/font-awesome-5/gitlab.puml !include ICONURL/font-awesome-5/java.puml !include ICONURL/font-awesome-5/rocket.puml !include ICONURL/font-awesome/newspaper_o.puml FA_NEWSPAPER_O(news,good news!,node) #White { FA5_GITLAB(gitlab,GitLab.com,node) #White FA5_JAVA(java,PlantUML,node) #White FA5_ROCKET(rocket,Integrated,node) #White } gitlab ..> java java ..> rocket ``` ~~~
**Output** {: .panel-heading}
```plantuml !define ICONURL https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/v2.1.0 skinparam defaultTextAlignment center !include ICONURL/common.puml !include ICONURL/font-awesome-5/gitlab.puml !include ICONURL/font-awesome-5/java.puml !include ICONURL/font-awesome-5/rocket.puml !include ICONURL/font-awesome/newspaper_o.puml FA_NEWSPAPER_O(news,good news!,node) #White { FA5_GITLAB(gitlab,GitLab.com,node) #White FA5_JAVA(java,PlantUML,node) #White FA5_ROCKET(rocket,Integrated,node) #White } gitlab ..> java java ..> rocket ```
## Videos There are two ways of displaying videos: within HTML5 `