Creating Your Site's Content

Markdown

Have some pages you'd rather write in Markdown than Blade? We know the feeling.

Using Markdown in Jigsaw is as simple as using a .markdown or .md extension, and specifying a few details in YAML front matter.

For example, say you have this layout and you'd like to populate the content section using Markdown:

1<html>
2 <head><!-- ... --></head>
3 <body>
4 @yield('content')
5 </body>
6</html>

If that layout was named master in the _layouts folder, you could create a Markdown page that used this layout like so:

1---
2extends: _layouts.master
3section: content
4---
5 
6# My awesome heading!
7 
8My awesome content!

The end result would be a generated page that looked like this:

1<html>
2 <head><!-- ... --></head>
3 <body>
4 <h1>My awesome heading!</h1>
5 <p>My awesome content!</p>
6 </body>
7</html>

Custom front matter variables

Imagine you have a layout named post.blade.php in your _layouts folder that looks like this:

_layouts/post.blade.php

1@extends('_layouts.master')
2 
3@section('content')
4 <h1>{{ $page->title }}</h1>
5 <h2>by {{ $page->author }}</h2>
6 
7 @yield('postContent')
8@endsection

You can populate the title and author variables by adding custom keys to the YAML front matter:

my-post.md

1---
2extends: _layouts.post
3section: postContent
4title: "Jigsaw is awesome!"
5author: "Adam Wathan"
6---
7 
8Jigsaw is one of the greatest static site generators of all time.

...which would generate this:

1<html>
2 <head><!-- ... --></head>
3 <body>
4 <h1>Jigsaw is awesome!</h1>
5 <h2>by Adam Wathan</h2>
6 
7 <p>Jigsaw is one of the greatest static site generators of all time.</p>
8 </body>
9</html>


Formatting dates

The YAML processor converts any dates that it finds in a Markdown file's front matter into integer timestamps. When outputting a date variable in your Blade template, you can use PHP's date() function to specify a date format. For example:

my-post.md

1---
2extends: _layouts.post
3section: postContent
4date: 2018-02-16
5---

_layouts/post.blade.php

1<p>The formatted date is {{ date('F j, Y', $post->date) }}</p>


Specifying a permalink

You can specify a permalink in the YAML front matter to override the default path of a file when your site is built. This can be used, for example, to create a custom 404 page that is output to 404.html (instead of the default 404/index.html):

source/404.md

1---
2extends: _layouts.master
3section: content
4permalink: 404.html
5---
6 
7### Sorry, that page does not exist.