Thea » In-Depth

Thea requires 4 folders at the root of your project (see the starter kit for a practical example):

config/

This is where your configuration file(s) live. The only required file within this directory is default.toml which is where you'll define your page types and template globals (see example file below).

You can optionally create a development.toml and/or production.toml file with environment-specific settings that'll be applied on top of default.toml, overwriting any matching keys. For example, you can set a base_url key in templates.globals to have a value of http://127.0.0.1:8765 during local development, and a value of https://elliotekj.com in production. Thea determines the environment via the THEA_ENV environment variable. If no value is found, Thea will assume it's in a development environment. Acceptable values are:

config/default.toml
1# [1]: write_to_disk (default: false, required: false)
2# If true, Thea will write the contents of the HashMap to a .rendered/
3# directory in your project. This is only useful for utilities like purgecss.
4write_to_disk = true # [1]
5
6# [2]: path (default: "content", required: false)
7# The path to the directory that will hold your page type folders.
8#
9# [3]: syntax_theme (default: "InspiredGitHub", required: false)
10# The theme Thea should highlight syntax with.
11# Available values:
12# * "base16-ocean.dark"
13# * "base16-eighties.dark"
14# * "base16-mocha.dark"
15# * "base16-ocean.light"
16# * "InspiredGitHub"
17# * "Solarized (dark)"
18# * "Solarized (light)"
19[content]
20path = "content" # [2]
21syntax_theme = "Solarized (dark)" # [3]
22
23# [4]: content.page_types item (required: at least 1)
24#
25# [5]: type (required: true)
26# A given name for the type that will be available in your template files
27# for things like filtering: {{ page.page_type }}.
28#
29# [6]: path (required: true)
30# The folder within content/ where pages of this type live. In this case,
31# all files within content/posts/ will be assigned the "post" page type.
32#
33# [7]: default_layout (required: true)
34# The name of the template file within templates/ that pages of this type
35# should default to if no "layout" key/value is present in their frontmatter.
36[[content.page_types]] # [4]
37type = "post" # [5]
38path = "posts" # [6]
39default_layout = "blogpost.html" # [7]
40
41[[content.page_types]]
42type = "page"
43path = "pages"
44default_layout = "base.html"
45
46[[content.page_types]]
47type = "spaceship"
48path = "spaceships"
49default_layout = "spaceship.html"
50
51# [8]: redirects item (required: false)
52#
53# [9]: type (required: true)
54# Available values:
55# * "permanent"
56# * "temporary"
57#
58# [10]: from (required: true)
59# The slug to be redirected.
60#
61# [11]: to (required: true)
62# The slug to be redirected to.
63[[redirects]] # [8]
64type = "permanent" # [9]
65from = "/feed.xml" # [10]
66to = "/rss.xml" # [11]
67
68[[redirects]]
69type = "temporary"
70from = "/about-me"
71to = "/about"
72
73# [12]: path (default: "templates", required: false)
74# The path to the directory that will hold your template files.
75[templates]
76path = "templates" # [12]
77
78# [13]: templates.globals (default: {}, required: false)
79# Global key/value pairs that are made available to your template files: {{ globals.base_url }}
80[templates.globals] # [13]
81base_url = "http://127.0.0.1:8765"
82title = "Elliot Jackson: Freelance software designer and developer"
83desc = "I'm Elliot Jackson; I build software for a living and write about Swift, Rust, and other things."
84something = "cool"

content/

This is where you create the folders for your page types. If my project was using the default.toml file above, for example, I'd create the following folders:

A page type folder can contain any number of files and sub-directories, the only requirement being that every file must have a slug key in its frontmatter. Thea does not take directory structure into account when creating and matching slugs. You can create a content/pages/homepage.md file with slug: "/" frontmatter and when someone visits the root of your domain, that's the page that'll be matched.

Thea assigns the appropriate Content-Type header to slugs that have any of the following extensions:

If a slug doesn't have an extension, it'll be assigned a text/html Content-Type header. Slugs with extensions other than those listed will be assigned a text/plain Content-Type header.

static/

This is where you should put image files, videos, etc. The contents of this directory isn't loaded into the HashMap but is accessible via yourdomain.com/static/your/file/path.png. Due to the performance strategies applied to pages served from the HashMap, you should favour creating an "assets" page type and keeping JavaScript & CSS files in your content/ folder.

templates/

This is where all your layout files live. Thea uses the brilliant Tera as a template engine and it, along with the global access to your content Thea provides, allows for some truly powerful templating.

Every template file has access to 3 top-level data sources:

A page consists of 4 key/values:

[Back to docs]