Fast, opinionated and simple static site generator.
Gozer is a fast & simple static site generator written in Golang.
- Converts Markdown and djot to HTML.
- Allows you to use page-specific templates.
- Creates an XML sitemap for search engines.
- Creates an RSS feed for feed readers.
Sample websites using Gozer:
- Simplest possible example
- My personal website: site - source
You can install Gozer by first installing a Go compiler and then running:
go install github.com/dannyvankooten/gozerRun gozer new to quickly generate an empty directory structure.
├── config.toml # Configuration file
├── content # Posts and pages
│ └── index.md
├── public # Static files
└── templates # Template files
└── default.htmlThen, run gozer build to generate your site.
Any Markdown files placed in your content/ directory will result in an HTML page in your build directory after running gozer build.
For example:
content/index.mdcreates a filebuild/index.htmlso it is accessible over HTTP at/content/about.mdcreates a filebuild/about/index.htmlso it is accessible over HTTP at/about/.
Run gozer without any arguments to view the help text.
Gozer - a fast & simple static site generator
Usage: gozer [OPTIONS] <COMMAND>
Commands:
build Deletes the output directory if there is one and builds the site
serve Builds the site and starts an HTTP server on http://localhost:8080
watch Builds the site and watches for file changes
new Creates a new site structure in the given directory
Options:
-r, --root <ROOT> Directory to use as root of project (default: .)
-c, --config <CONFIG> Path to configuration file (default: config.toml)
--listen <INTERFACE:PORT> Interface to liston on; only used with 'serve',
'INTERFACE' is optional. e.g. '--listen :9000'
Each file in your content/ directory should end in .md or .dj and have TOML front matter specifying the page title:
+++
title = "My page title"
+++
Page content here.djot note djot has not settled on a syntax for front matter. Until issue #35 is resolved, TOML front matter in djot documents are used.
The default template for every page is default.html. You can override it by setting the template variable in your front matter.
+++
title = "My page title"
template = "special-page.html"
+++
Page content here.Templates are powered by Go's standard html/template package, so you can use all the actions described here.
Every template receives the following set of variables:
Pages # Slice of all pages in the site
Posts # Slice of all posts in the site (any page with a date in the filename)
Site # Global site properties: Url, Title
Page # The current page: Title, Permalink, UrlPath, DatePublished, DateModified
Title # The current page title, shorthand for Page.Title
Content # The current page's HTML content.
Now # Timestamp of build, instance of time.Time
The Page variable is an instance of the object below:
type Page struct {
// Title of this page
Title string
// Template this page uses for rendering. Defaults to "default.html".
Template string
// Time this page was published (parsed from file name).
DatePublished time.Time
// Time this page was last modified on the filesystem.
DateModified time.Time
// The full URL to this page, including the site URL.
Permalink string
// URL path for this page, relative to site URL
UrlPath string
// Path to source file for this page, relative to content root
Filepath string
}
To show a list of the 5 most recent posts:
{{ range (slice .Posts 0 5) }}
<a href="{{ .Permalink }}">{{ .Title }}</a> <small>{{ .DatePublished.Format "Jan 02, 2006" }}</small><br />
{{ end }} from https://github.com/,/gozer--------------------------------------------------------搭建基于go的静态博客生成器gozer首先安装go环境,然后 go install github.com/dannyvankooten/gozer@latest运行此命令后,就会生成可执行文件gozer.然后fork此项目 https://github.com/dannyvankooten/www.dannyvankooten.com,我fork后的项目地址是 https://github.com/briteming/wdc。git clone https://github.com/dannyvankooten/www.dannyvankooten.com wdccd wdc 12799@DESKTOP-B6LK9IO MINGW64 ~/wdc (main)
$ ls
LICENSE bin/ config.toml content/ templates/
README.md config_prod.toml public/
12799@DESKTOP-B6LK9IO MINGW64 ~/wdc (main)
$ gozer build(此即生成/更新静态网站的根目录的命令) 12799@DESKTOP-B6LK9IO MINGW64 ~/wdc (main)
$ ls
LICENSE bin/ config.toml content/ templates/
README.md build/ config_prod.toml public/(生成了build目录)
12799@DESKTOP-B6LK9IO MINGW64 ~/wdc (main)
$ cd build12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/build (main)
$ ls
2023/ code/ img/ privacy-policy/ sitemap.xsl
2025/ contact/ index.html projects/ style.css
404/ donate/ links/ public-key.txt wordpress-plugins/
about/ favicon.ico media/ robots.txt
blog/ feed.xml notebooks/ rss-icon.svg
bookmarks/ hire-me/ now/ sitemap.xml(可见~/wdc/build就是静态网站的根目录)12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/build (main)
$新建源帖:12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/build (main)
$ cd ../content
12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/content (main)
$ ls
404.md bookmarks.md donate.md links.md projects.md
about.md code.md hire-me.md now.md wordpress-plugins.md
blog/ contact.md index.md privacy-policy.md
12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/content (main)
$ cd blog
12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/content/blog (main)
$ ls
2010/ 2012/ 2014/ 2016/ 2018/ 2020/ 2022/ 2024/ index.md
2011/ 2013/ 2015/ 2017/ 2019/ 2021/ 2023/ 2025/
12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/content/blog (main)
$ mkdir 2026 && cd 202612799@DESKTOP-B6LK9IO MINGW64 ~/wdc/content/blog/2026 (main)
$ nano 2026-02-24-fh.md12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/content/blog/2026 (main)
$ cat 2026-02-24-fh.md显示:+++
title = "战马"
+++此处为html codes或正文12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/content/blog/2026 (main)
$ cd ~/wdc/
12799@DESKTOP-B6LK9IO MINGW64 ~/wdc (main)
$ ls
LICENSE bin/ config.toml content/ templates/
README.md build/ config_prod.toml public/
12799@DESKTOP-B6LK9IO MINGW64 ~/wdc (main)
$ gozer build12799@DESKTOP-B6LK9IO MINGW64 ~/wdc (main)
$ cd build
12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/build (main)
$ ls
2023/ code/ img/ privacy-policy/ sitemap.xsl
2025/ contact/ index.html projects/ style.css
404/ donate/ links/ public-key.txt wordpress-plugins/
about/ favicon.ico media/ robots.txt
blog/ feed.xml notebooks/ rss-icon.svg
bookmarks/ hire-me/ now/ sitemap.xml
12799@DESKTOP-B6LK9IO MINGW64 ~/wdc/build (main)
$ python3 -m http.server 2000在浏览器里,访问http://localhost:2000/,即可看到静态网站的效果。如图:
访问https://app.netlify.com/drop,然后在电脑上,进入C:\Users\你的用户名\wdc目录,把build目录拖放到
页面https://app.netlify.com/drop里的圆圈里,等待上传完成,上传完成后,我得到了网址https://jazzy-scone-580b6a.netlify.app/ https://jazzy-scone-580b6a.netlify.app/blog/。同一天里的帖子是按字母顺序从下到上排列的: https://jazzy-scone-580b6a.netlify.app/blog/2026/test/ https://jazzy-scone-580b6a.netlify.app/blog/2026/fh/https://jazzy-scone-580b6a.netlify.app/blog/2026/ce/

No comments:
Post a Comment