Code snippet#
Code fragment#
To define a code fragment, add a backtick (`) before and after the code to highlight.
Markdown | HTML | Rendering |
---|---|---|
| <p>Enter <code>hugo version</code> to get the Hugo version</p> | Enter hugo version to get the Hugo version |
Nested code fragment#
To define a nested code fragment, add two backticks (`) before and after the global text that will contain the nested code fragment.
Markdown | HTML | Rendering |
---|---|---|
| <p><code>Enter `hugo version` to get the Hugo version</code></p> | Enter `hugo version` to get the Hugo version |
Code block#
To define a code block over several lines, add 4 spaces to each line start of code.
Markdown | HTML | Rendering |
---|---|---|
| <pre>
<code>
<html>
<head>
<title>Hello world</title>
</head>
</html>
</code>
</pre> |
|
Fenced code block#
Classic syntax#
To define a fenced code block over several lines, add 3 backticks (`) at the start of two new lines, before and after the code to highlight.
Markdown | HTML | Rendering |
---|---|---|
| <pre>
<code>
<html>
<head>
<title>Hello world</title>
</head>
</html>
</code>
</pre> |
|
Classic syntax with highlighting#
To define a fenced code block with code highlighting based on the language used, add the language code after the 3 backticks (`) to the first line.
Markdown | HTML | Rendering | ||
---|---|---|---|---|
| [...]
<pre>
<code>
<html>
<head>
<title>Hello world</title>
<meta charset="UTF-8">
</head>
</html>
</code>
</pre>
[...] |
|