mna/trofaf: Super simple live static blog generator in Go. Vraiment trofaf.
December 19, 2024

mna/trofaf: Super simple live static blog generator in Go. Vraiment trofaf.

Trofaf is a super simple live Static blog engine.

Install using: go get github.com/PuerkitoBio/trofaf

It produces a static website price reduction document As with the previous content, only a simple 3 directory structure is needed to get started. It prefers simplicity over functionality.

First, create 3 subdirectories (you can view example/ Subdirectory…Example):

Trofav only cares about *.md files in the posts directory and related *.amber (amber template) or *.html (Native Go template) files in the template directory. It will monitor the files in these directories for changes, creation or deletion and automatically regenerate the website if needed. This is live part.

All files in the public directory are exposed by the web server. Posts in Markdown format will be converted into static html files in the root directory of the public directory. The html file name is a URL-friendly slug generated from the original Markdown file name. There are no extensions so the URL looks clean and, uh, modern?

RSS feeds are automatically generated based on many recent posts and saved as static XML archives in a public directory.

There is no special template for the index page, the latest post (based on the published date found in the previous text of the markdown file) is saved twice – once under its own html file and once under the index.html file, so this is the request to the web server The page displayed when the root directory.

When the site is (re)spawned, the public directory must be cleaned as some posts may have been deleted. subdirectories remain unchanged (such css/ or js/ Directories can coexist peacefully), as well as hidden (dot) files, and some special files are protected from corruption (robots.txt, favicon.ico, etc., see gen.go).

It currently uses my amber bag fork in order to make fmttime(t time.Time, fmt string) string Features available in the template. This function can format PubTime or ModTime Fields behave in the same way as stdlib’s fields time.Format() work. This feature is also available with native Go templates (you can see usage examples).

The following options can be set on the command line:

  • Port (-p): The port number of the Web server, the default is 9000.
  • GenOnly (-g): Generate a static website and exit.
  • NoGen (-G): Blocks viewing and instant generation of sites. This is equivalent to running a static public directory.
  • SiteName (-n): The website name passed to the template.
  • TagLine (-t): The website tag line passed to the template.
  • RecentPostsCount (-r): Number of posts in the recent posts list, passed to the template and used in the RSS feed.
  • BaseURL (-b): The base URL of the website, most likely the hostname (i.e. http://www.mysite.com).

Like many static blog generators, trofaf uses YAML Preface Get the metadata of the post. This is a complicated way of saying that you have to add a block of text like this at the beginning of your post:

---
Title: My title
Description: My short-ish description of the post.
Author: Me
Date: 2013-07-14
Lang: en
---

# Here is my post!

Etc.

Three dashes define what comes before it. It has to be there, beginning and ending. The part between dashes and before colon : is the key, followed by the value. It’s that simple. Title, description, author, date and language are identified. Valid date formats are 2006-01-02, 2006-01-02 15h (or 2006-01-02 8h), 2006-01-02 15:04 (or 2006-01-02 8:17) or RCF3339 format (2013-08-06T17:48:01-05:00).

this BSD 3-clause license.

2024-12-17 22:43:10

Leave a Reply

Your email address will not be published. Required fields are marked *