1.4 KiB
1.4 KiB
Layouts A way to creating template of page and also supporting markdown
- In root directory (
sitehere) create_layoutsand createdefault.htmlIn_layouts/default.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>{{ page.title }}</title>
</head>
<body>
{{ content }}
</body>
</html>
- html
---
layout: default
title: Home
---
<h1>{{ "Hello World!" | downcase }}</h1>
- create a about.md file in root directory of site and add following
---
layout: default
title: About
---
# About page
This page tells you a little bit about me.
Now opening http://localhost:4000/about.html will open this about.md with markdown content rendered
Includes
- The
includetag allows you to include content from another file stored in an_includesfolder. at_includes/navigation.html. herepage.urlis used to detect url so that current page link will be colored as red
<nav>
<a href="/" {% if page.url=='/' %} style="color: red;"{% endif %} >Home</a>
<a href="/about.html" {% if page.url=='/about.html' %} style="color: red;"{% endif %} >About</a>
</nav>
Now using this in _layouts/default.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>{{ page.title }}</title>
</head>
<body>
{% include navigation.html %}
{{ content }}
</body>
</html>