In this recipe, we will look at observing the don't repeat yourself principle. By separating our code into partials, and using Jekyll's front matter, we will achieve just that.
To start off, navigate to chapter10/complete/recipe2
and run the console from this folder. Start the Jekyll server by running the jekyll serve --watch
console command. Open your browser, point it to localhost:4000
and preview the result. Click on some of the links on the navbar to see how it behaves.
- Open the folder titled
chapter10/start/recipe2
in Bash. - Create a new file inside the
_layouts
folder by typing the following command:
touch _layouts/default-layout.html
- Cut the first 11 lines from
index.html
and paste them inside_layouts/default-layout.html
. Your_layouts/default-layout.html
file should now look like this:
<!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name...