Using Templates

Here's how to use templates in Eggspress
December 7, 2023

Eggspress comes with a set of template files, two for each of the content types (posts, pages, authors, categories, and sidebars). They are easy to use and let you create new posts quickly.

Why use templates

Eggspress brings together individual content files to build into a site. In addition to the text and images that fill the body of a page, these files also include a lot of frontmatter, which holds data about:

  • Metadata
  • References to other files
  • Settings unique to the content's rendered page

While it's easy enough to copy and paste frontmatter from the most recent post into a new post, doing so can often result in errors. For example, you may forget to update the date field or set the correct relatedPost.

Templates give you a fresh start with each new content file you create.

Using templates with Obsidian

Obsidian is our recommended desktop editor because its features make publishing on Eggspress a breeze. One benefit of using Obsidian is that it has a dedicated function for inserting templates.

To use a template in Obsidian:

  1. Create a new note and give it a filename
  2. Click the "Insert template" button on the left-hand ribbon
  3. Select the template you wish to insert
  4. Begin editing your new file

You'll notice that title will be pre-populated using the filename you gave your file. date will also have the current time.

Using templates with other editors

If your desktop editor supports templates, you'll want to set your templates folder to my_templates. Otherwise, the best way to use templates is to locate the template you want from my_templates and copy and paste its contents into a new file.

Creating new templates

If you find yourself modifying the same frontmatter fields over and over again, you might wish to consider creating your own template. To do so:

  1. Create a copy of an existing template you want to use for your new template
  2. Rename this file with a descriptive name, but note that it must start with #
  3. Set the values for your fields

In Obsidian, you can use the strings "{{title}}" and "{{date}}" in your templates. Obsidian will automatically replace these strings with the filename of your target file and the current date, respectively.

To change the date format,

  1. Open settings (gear wheel icon on the bottom-left corner)
  2. Select the "Templates" tab
  3. Set "Date Format" to the format you wish to use
Profile image for Denton Zhou
Denton Zhou
Maintainer
I'm here to help you start your new site using Eggspress!
Twitter: @dentonzh
Social: LinkedIn
relation icon
Related Posts
Editing Eggspress Content
November 23, 2023
In this fifth and final part of our Getting Started Guide, we'll walk you through how to edit files in your workspace and customize their appearance to get the results you want.
Read more
Using Frontmatter
November 29, 2023
Frontmatter contains data that can help create better experiences for you and your readers. Learn how frontmatter works and our advice for using it.
Read more
logo