Adding Code to Markdown Files

Adding Code Blocks

To create a code block, indent the entire block of code in the Markdown file. This will create an output like this:

        All our code here,
            indented how we like.
                like ;)

Add a blank line around the code to make sure it works as expected.

Adding Inline Code

To add inline code, surround the code with backticks in the Markdown file. This is a backtick: `. It's on the same key as the tilde/~.

Adding Nunjucks Code for Display

In my Eleventy setup, I've told Eleventy to process any Nunjucks it finds in my Markdown files. (Feel free to correct me if this isn't why it renders it).

So, if I want to actually display the Nunjucks code instead of it getting rendered, the entire block that includes the Nunjucks has to be surrounded with {% raw %} {% endraw %}, like this:

{% raw %}
<style>{% include "css/critical.css" %}</style>

    {# Add facility for pages to delare an array of critical styles #}
    {% if pageCriticalStyles %}
    {% for item in pageCriticalStyles %}
        <style>{% include item %}</style>
    {% endfor %}
    {% endif %}
{% endraw %}