config/template-path
The template path is the direct-file default and one of three ways to define the template for a file. A template is basically the shell for a Markdown file. When it's converted to HTML, it's placed inside said shell which contains things like a sidebar and has the CSS defined.
umejs chooses a template in the following order of preference:
- if a template is defined in frontmatter, that one is used. (Note: you would have to make this accessible via the
templateDirkey in ume options; themes can make theirs accessible as well) - the default template file as defined in
templatePathis used - the default template chosen by the theme is used
Meaning, if you're using a theme, you can override their default template of choosing by making your own.
As your template is an HTML file that can be fully parsed with umejs, you should make the file extension .ume.html, to make clear that is can only be properly rendered using umejs. It's not an enforced requirement though, you can name it however you please. I'm not your mum.
Here's an example definition inside your configuration:
const ume = require('@dantenl/umejs');
const path = require('path');
ume({
templatePath: path.join(__dirname, 'layout.ume.html'),
// ! you'll also need to define contentDir if you want a valid umejs config!
});
Inside this file, you will also need the actual template. This is basically the wrapper for your Markdown (once converted to HTML) and is placed inside it. Here's an incredibly simple example of a template file:
<!-- layout.ume.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{_SLUG}</title>
</head>
<body>
{_BODY}
</body>
</html>
umejs will automagically replace {_BODY} with the generated HTML page.
Inside the layout file, you're free to use all variables. For example, you could define a {title} variable in your Markdown document and you could then reference said title as the <title> element. Here's what that would look like:
---
title: My Article
---
# Hello world!
In the layout.ume.html file, you'd simply replace {_SLUG} with {title}.