Routing

When a request from one of your readers arrives at your blog, Blot follows these steps to work out what to send in response.

  1. Check if there is a template whose route matches the request’s path. Render the template if it matches.
  2. Check if there is a file which matches the request’s path in your blog’s folder. Send the file as a response if it matches.
  3. Check your site's list of redirects.
  4. Render your blog’s error page.

Rendering

Blot's templates are written in Mustache. Consider this example template, which produces a list of all of the posts on your blog:

1
2
3
4
5
6
7
8
9
10
11
<html>
<title>{{title}}</title>
<body>
{{#all_posts}}
  <a href="{{url}}">{{title}}</a><br>
{{/all_posts}}
</body>
</html>

Blot generates JSON containing the data for this template:

1
2
3
4
5
6
7
8
9
10
11
{
  "title": "Your blog's title",
  "all_posts": [
    {"title": "First post", "url": "/first-post"},
    {"title": "Second post", "url": "/second-post"},
    {"title": "Third post", "url": "/third-post"}
  ]
}

Blot then renders the template to produce this HTML:

1
2
3
4
5
6
7
8
9
10
11
<html>
<title>Your blog's title</title>
<body>
  <a href="/first-post">First post</a><br>
  <a href="/second-post">Second post</a><br>
  <a href="/third-post">Third post</a><br>
</body>
</html>

Retrieving the JSON used to render a template

If you append the query string ?json=true to the URL of any page on your blog, you can see the JSON used to render its template.

Using static files in your templates

Remember that your blog's folder behaves like a static file server. This makes it possible to share assets between your templates.

Custom metadata

You can create your own metadata. There's no configuration neccessary. Just choose a property that isn't already used by Blot, like Author for example:

 Text 
Author: Eric Blair

Metadata keys should be a single word. They are case insensitive



Once the property exists in a file, you can use it in your template:

1
2
3
4
5
6
7
8
9
10
11
<html>
<title>{{title}}</title>
<body>
{{#entry}}
  <p>Posted by {{metadata.author}}</p>
  ...
{{/entry}}
</body>
</html>