philote
Minimalist library to serve markdown content as webpages.
Index
Disclaimer
This library is under active development and subject to breaking changes at any time.
Install
go get github.com/fuzzingbits/philote
Getting Started
The following steps are how the Getting Started Example was created.
- Serve a philote.Site
// Create your instance of the philote.Site
site := &philote.Site{
Content: os.DirFS("./content"),
Template: template.Must(template.ParseFiles("./template.go.html")),
}
// Prime the site
if err := site.Prime(); err != nil {
panic(err)
}
// Serve the site
http.ListenAndServe(":8090", site)
- Create the Go HTML Template (
./template.go.html
):
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Philote Site</title>
</head>
<body>
<h1>Title: {{.Taxonomy.FrontMatter.Title}}</h1>
<p>Description: {{.Taxonomy.FrontMatter.Description}}</p>
{{.Taxonomy.Render}}
</body>
</html>
- Create your first page (
.content/index.md
):
---
title: My First Page
date: 2021-01-01T00:00:00Z
description: "This is my first page"
---
This is being served with [philote](https://github.com/fuzzingbits/philote).
Templates
Taxonomy
The Site Taxonomy is automatically derived from the contents of the Content FileSystem:
- all files are used as pages with their path and base filename used as the URL
- Example:
./posts/hello-world.md
== http://localhost:8000/posts/hello-world
- all files must be have the
.md
extension
- every directory (including the root directory) must include a
index.md
file.
Example:
┌── index.md
├── about.md
└── posts
├── index.md
└── hello-world.md
FrontMatter
Every Markdown file must include FrontMatter at the beginning of the file. The FrontMatter should be in YAML format with fields matching the FrontMatter struct.
Example:
---
title: My First Page
date: 2021-01-01T00:00:00Z
description: "This is my first page"
---
This is being served with [philote](https://github.com/fuzzingbits/philote).