Skip to content

Latest commit

History

396 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

pt

Release

A minimalist static blog generator.

Basic example

echo'Some `cool` _arbitrary_ **Markdown**!'| pt

Which prints:

<!DOCTYPE html><htmllang=""><head><title></title><metacharset="utf-8"><metaname="viewport" content="width=device-width, initial-scale=1"></head><body><p>Some <code>cool</code><em>arbitrary</em><strong>Markdown</strong>!</p></body></html>

Installation

go install github.com/hoffa/pt@latest

Or check releases for the latest binaries.

Usage

Usage of pt:
-base-url string
base URL
-dir string
where to save generated files (default ".")
-feed string
feed target path (default "feed.xml")
-feed-template string
feed template path
-highlight string
code highlight style
-template string
page template path

Pass the list of Markdown files to convert at the end.

Front matter

Each page can contain a YAML front matter. It must be placed at the top within --- delimiters:

---title: Hello, world!date: 2019-02-11---
This is an example page!

Valid variables are:

  • title: page title
  • date: page creation date
  • exclude: if yes, the page will be excluded from .Pages and the RSS feed
  • .Title: page title
  • .Date: page creation date
  • .Path: path to the generated HTML file
  • .Content: content of the generated HTML file
  • .URL: URL of the generated HTML file prefixed by the value of -base-url
  • .Exclude: boolean specifying whether this page is in .Pages
  • .Pages: array of all non-excluded pages sorted by date

See templates/page.html and templates/feed.xml for the default templates.

Longer example

Create a page template as template.html:

<!DOCTYPE html><html><head><title>{{ .Title }}</title><metacharset="utf-8"><metaname="viewport" content="width=device-width, initial-scale=1"></head><body>
{{ if eq .Path "index.html" }}
{{ .Content }}
<ul>
{{ range .Pages }}
<li><ahref="{{ .URL }}">{{ .Title }}</a> ({{ .Date.Format "January 2, 2006" }})</li>
{{ end }}
</ul>
{{ else }}
{{ .Content }}
{{ end }}
</body></html>

Create the index page as index.md:

---title: Jane Doeexclude: yes---
Subscribe via [RSS](/feed.xml).

And a post within a file called my-first-post.md:

---title: My first postdate: 2019-04-20---
This is an example **Markdown**_post_.
I like `turtles`.
```pythonprint("Hello!")
```

Finally, build:

pt -base-url https://mysite.com -template template.html -highlight monokailight *.md

See the Chroma Playground for available syntax highlighting styles.

About

Minimalist static site generator

Resources

Stars

27 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages