Setup Eleventy

Install Eleventy

npm install @11ty/eleventy --save-dev

Append Eleventy build folder to gitignore

echo '' >> .gitignore
echo "# Eleventy build folder" >> .gitignore
echo "_site" >> .gitignore

Add index.md

touch index.md

Write index.md

# Hello markdown world!
Welcome to our home page!  
Checkout our code snippets!  

Add base.html layout

mkdir _includes
touch _includes/base.html

Write base.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width; initial-width=1.0">
    <title>Code Docs</title>
  </head>
  <body>
    {{ content }}
  </body>
</html>

Add Eleventy config file

touch eleventy.config.js

Write Eleventy configuration


// Dynamic setup and plugins
export default async function(eleventyConfig) {
  eleventyConfig.addGlobalData("layout", "base.html");
};

// Static settings
export const config = {
  setTemplateFormats: ["md", "html"],
  markdownTemplateEngine: false,
  htmlTemplateEngine: "liquid",
  dir: {
    input: ".",
    output: "_site"
  }
};

Add build and serve scripts to package.json

npm pkg set scripts.build="eleventy"
npm pkg set scripts.serve="eleventy --serve"

Test setup and view in browser

npm run serve

Commit

git add .
git commit -m 'Adds eleventy setup'
git push

Next:
Add New Page