If you haven't created a Zola site yet, create a new Zola site with the following command (assuming your site is called myblog):
zola init myblogEnter the directory:
cd myblogAdd the Tranquil theme:
git submodule add https://github.com/teadrinkingprogrammer/tranquil.git themes/tranquilThe myblog directory now looks like this:
├── config.toml
├── content/
├── sass/
├── static/
├── templates/
└── themes/
└── tranquil/
Create myblog/content/_index.md and myblog/content/blog/_index.md
If you want to display the projects page, also create myblog/content/projects/_index.md
├── config.toml
├── content/
│ ├── blog/
│ │ └── _index.md
│ ├── projects/
│ │ └── _index.md
│ └── _index.md
├── sass/
├── static/
├── templates/
└── themes/
└── tranquil/
Modify the content of these files as follows:
myblog/content/_index.md:
+++
template = 'home.html'
[extra]
lang = 'en'
+++
Words about you
myblog/content/blog/_index.md:
+++
title = "My Blog"
description = "My blog site."
sort_by = "date"
template = "blog.html"
page_template = "post.html"
insert_anchor_links = "left"
generate_feed = true
[extra]
lang = 'en'
display_tags = true
truncate_summary = false
+++
myblog/content/projects/_index.md:
+++
title = "My Projects"
description = "My projects page."
template = "projects.html"
[extra]
lang = 'en'
+++
Create a new directory icons under myblog/static and place your favicons. I recommend first compressing your logo using TinyPNG and then using RealFaviconGenerator to generate your favicons. At the bottom of the selection screen, set the path to "icons" and paste your generated favicons in this folder.
Also put your avatar picture file avatar.webp in this folder, preferably in webp format.
...
├── static/
│ └── img/
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── apple-touch-icon.png
│ └── avatar. webp
...
Copy the contents of myblog/themes/tranquil/config.example.toml to myblog/config.toml, refer to the comments in the file and Zola's documentation to modify accordingly.
- Copy
myblog/themes/tranquil/static/icondirectory tomyblog/static/icon.
To change the Icons for links (like social media), place a
-
Find the svg file of the icon you want, modify its width and height to 24, and the color to currentColor:
... width="24" height="24" ... fill="currentColor" ... -
The default icons are from HeroIcons and Simple Icons. The logos from Simple Icons were modified with
fill="currentColor" class="w-6 h-6"at the end of their SVG tag (check the Github icon for more info).
-
Copy
myblog/themes/tranquil/highlight_themesdirectory tomyblog/highlight_themes. Alternatively, use symlinks (mklink /H on windows, ln -s on Linux) to link the theme files. In this case, make a relative link from myblog/highlight_themes to ../themes/tranquil/highlight_themes/ (use \ for Windows) for both tranquil-light.tmTheme and tranquil-dark.tmTheme. -
If you set
highlight_themeinconfig.tomlto one of Zola's built-in highlight themes, you will get that theme used in both light and dark mode. -
By default Tranquil use different themes for light/dark modes, configured by
highlight_theme,extra_syntaxes_and_themesandhighlight_themes_css. The default highlight themetranquil-lighttranquil-darkis a modified version of Serenes version of Tomorrow with the background changed to work with Tailwind. -
If you want a different theme, find the
.tmThemeTextMate file of your theme, put it inmyblog/static/highlight_themes, and then modify thethemevalue ofhighlight_themes_cssto that file's name, without.tmThemeextension. This will generate ahl-light.cssand ahl-dark.cssfile inmyblog/static/, you may have to delete them first before you change thethemevalue, so Zola can re-generate. To make the theme work play nice with Tailwind, you could change the background colors to one of the values of the default pallet. The default theme uses the stone theme.
...
<string>Tomorrow Night</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#292524</string> <!-- This is the background value -->
<key>caret</key>
<string>#AEAFAD</string>
<key>foreground</key>
<string>#C5C8C6</string>
...- You can find some TextMate themes on this website.
-
You can add RSS or Atom to your site: Zola's default feed file is located in the root directory of the site, set
generate_feeds = trueinconfig.toml.feed_filenamescan be set to[atom.xml]or[rss.xml], corresponding to two different feed file standards. I currently only support one or the other, since I only support Atom on my own blogs, PRs are welcome. Setgenerate_feed = falseinmyblog/content/blog/_index.mdif you want to disable this feature. -
The Tranquil theme looks more like a personal website, the posts are in the
/blogdirectory. You may want the feed file to be in the/blogdirectory instead of the root directory, which requires you to setgenerate_feeds = falsefeed_filenames = "[atom.xml]"inconfig.toml, and setgenerate_feed = trueinmyblog/content/blog/_index.md
-
Tranquil has a projects page where you can showcase your projects, products, etc.
-
Set
projects_page = trueinconfig.toml, create a newdata.tomlundermyblog/content/projects, add projects information in it, the format is as follows:[[project]] name = "" desc = "" tags = ["", ""] links = [ { name = "", url = "" }, { name = "", url = "" }, ] [[project]] name = "" desc = "" tags = ["", ""] links = [ { name = "", url = "" }, { name = "", url = "" }, ]
-
If one of your posts quickly becomes outdated, you can set an outdated alert to be displayed on the page after certain days
-
outdate_alertandoutdate_alert_daysinconfig.tomlset the default values for whether to show an outdated warning and when respectably. The values can be overriden on individual posts. This is done by settingoutdate_alertinconfig.tomltofalse, and then enable it separately in the front matter of time-sensitive posts. -
outdate_alert_text_beforeandoutdate_alert_text_afterare the specific content of the alert, before and after the number of days respectively
-
Tranquil supports using giscus to enable comments.
-
To enable it, you need to create
myblog/templates/_giscus_script.htmland put the script configured on the giscus website into it, then change the value ofdata-themetohttps://<your-domain-name>/giscus_light.css, replace<your-domain-name>with you domain name, same asbase_urlinconfig.toml -
comment = trueinconfig.tomlsets all posts to enable comments, you can setcomment = falseunder[extra]in the front matter of the post to control whether a specific post displays comments
You can enable a "Call to action footer" for your blogs. This is a place to put an option for readers to subscribe to RSS, email etc.
Enable it by setting call_to_action_footer = true in config.toml. Add text to the footer using call_to_action_footer_text. You need to make a template yourself by making a file called _call_to_action_footer in the templates folder. This is an example of how you can use this template:
<div class="flex flex-col gap-8">
{% if page.extra.call_to_action_footer_text is defined %}{% set call_to_action_footer_text = page.extra.call_to_action_footer_text %}{% else %}{% set call_to_action_footer_text = config.extra.call_to_action_footer_text %}{% endif %}
<p class="[&>a]:underline [&>a]:underline-offset-4 [&>a]:decoration-2 [&>a]:decoration-sky-500 [&>a]:dark:decoration-sky-400">{{ call_to_action_footer_text | safe }} </p>
<div class="flex gap-5">
<form
class="flex flex-col gap-2 w-1/2"
>
<input aria-label="Email input field" class="p-2 bg-stone-300 dark:bg-stone-700n placeholder:text-slate-700 dark:placeholder:text-slate-900" placeholder="Enter your email address" type="email" name="email" id="bd-email" />
<input class="rounded-md text-black dark:bg-sky-600 p-2 bg-sky-500" type="submit" value="Subscribe" />
</form>
<div class="flex justify-center items-center w-1/2">
{% set rss_icon = load_data(path="static/icon/rss.svg") %}
{% if section.generate_feed -%}
<a class="" href="{{ config.base_url }}/blog/{{ config.feed_filename }}" aria-label="rss feed">{{ rss_icon | safe }}</a>
{% elif config.generate_feed -%}
<a class="" href="{{ config.base_url }}/{{ config.feed_filename }}" aria-label="rss feed">{{ rss_icon | safe }}</a>
{% endif %}
</div>
</div>
</div>Example of the config.toml:
call_to_action_footer_text = "Did you like this blogpost? Then consider subscribing via email or RSS. The email newsletter uses <a href=\"https://www.linktomailprovider.com" target=\"_blank\"> Mailprovider</a>."
call_to_action_footer = true
- To place scripts for analytics tools (such as Google Analytics, Umami, Goatcounter, etc.), you can create a new
myblog/templates/_head_extend.htmland put the corresponding content in it. The content of this file will be added to the html head of each page.
To customise the style, it is recommended to use inline Tailwind classes. Don't forget to run npx run tw or bun run tw in the themes/tranquil folder when editing HTML files or editing CSS files.
-
In most cases, you shouldn't have to edit the CSS override file. If you do want to edit the override CSS file directly, you need to edit it in
myblog/themes/tranquil/style/styles.css. This is because Tailwind cannot compile files that may or may not exist. -
Tranquil uses the Lato font of Brick by default. If you want a different font, create a new
myblog/templates/_custom_font.htmland put the font link tags you copied from google fonts website into it, and then modify--main-fontor--code-fontinmyblog/sass/main.scss. For performance reasons, you may want to self-host (Google) font files (optional):- Open google-webfonts-helper and choose your font
- Modify
Customize folder prefixof step 3 to/font/and then copy the css - Replace the content of
myblog/templates/_custom_font.htmlwith a<style> </style>tag, with the css you just copied in it. - Download step 4 font files and put them in
myblog/static/font/folder
-
If you want to customize more, you only need to copy the files under the
templates,static,sassdirectory in the correspondingthemes/tranquilto the same name directory of myblog, and modify it. Be careful not to directly modify the files under the Tranquil directory, because these modifications may cause conflicts if the theme is updated
-
The content inside the two
+++at the top of the post markdown file is called front matter, and the supported configuration items are as follows:+++ title = "" date = 2022-01-01 draft = true [taxonomies] categories = ["one"] tags = ["one", "two", "three"] [extra] lang = "en" toc = true comment = true copy = true math = false mermaid = false outdate_alert = true outdate_alert_days = 120 +++ new post about somthing... <!-- more --> more post content...
-
You can add a
<!-- more -->line, the content before it will become the summary/description of the post. You can settruncate_summary = trueinmyblog/content/blog/_index.mdto remove the summary from the post webpage. -
Put your post files in the
myblog/content/blogfolder. If you want your posts to stay hidden, setdrafttotrue.
-
Zola supports 'shortcodes', which can add some extra styles or templates for in addition to the standard markdown format
-
Zola support some annotations for code blocks. Tranquil adds another one to show the file name by a
codeblockshortcode:{% codeblock(name="path/to/file") %} // a markdown code block ... {% end %} -
In addition to the
of standard markdown, Tranquil also supports afigureshortcode to adds some explanatory text to the image, the format is as follows:{{ figure(src="path/to/img", alt="alt text", caption="caption text") }}This will be displayed as
<figure></figure>in HTML on the web page instead of<img>, and the content of the caption will be centered below the image. The alt attribute is optional but recommended to help enhance accessibilityAdding attribution information to images is very common, you can directly use the
viaattribute, which will display a link named via below the image:{{ figure(src="path/to/img", alt="some alt text", via="https://example.com") }}
-
Tranquil also uses shortcodes to implement callouts. You can see callouts in action on this page of the demo site. There are currently 6 types:
noteimportantwarningalertquestiontip. The format is as follows (the header attribute is optional):{% note(header="Note") %} note text {% end %} -
If people read your posts via rss reader, these callouts will appear as normal
<blockquote>
-
Set
math = truein the front matter to enable KaTeX support. -
Inline formula
$...$, block-level formula$$...$$
I personally do not use much math in my posts, so if you notice some funky formatting, please make an issue.
-
Set
mermaid = truein the front matter to enable Mermaid support, and then insert a chart in the following format:{% mermaid() %} flowchart LR A[Hard] -->|Text| B(Round) B --> C{Decision} C -->|One| D[Result 1] C -->|Two| E[Result 2] {% end %}
I also don't use Mermaid much myself, so if something is of, please make an issue.
I personally use Bun/bunx, but NPM, Yarn, PNPM or any other package manager will work just fine as well. I have purposefully ignored all lock files, because the package.json is only used to run 2 compilation commands.
Local preview:
Run Tailwind with --watch flag in one console (tranquil folder):
npx run twServe Zola (root folder)
zola serveBuild the site:
zola buildFor deployment, you can use Zolas documentation about deployment.
Next to the usual steps, you also need to run the tailwind compile command. For inspiration, have a look at the Github CI file of the demo website.
Please check the CHANGELOG on github for breaking changes before updating the theme
git submodule update --remote themes/tranquil