Static site generators
Static site generators are useful, however, they’re not all created the same.1In addition to their implementation language, a major difference is the input format that is supported. This is a pity, because it means the choice of using one vs another can have consequences that only become apparent after the fact. How much Go do you need to know to extend syntax highlighting for a static site generator written in Go? Which one should you prefer if your intent is personal blogging vs building websites for clients? By the end of this post you should be able to answer some of these questions.
What are static site generators
From Wikipedia:
Static site generators (SSGs) are engines that use text input files (such as Markdown, reStructuredText, and AsciiDoc) to generate static web pages.[ 1] Static sites generated by static site generators do not require a backend after site generation …
Not needing a backend2And, thus, not needing to manage state server-side., makes them attractive for the usecases where they are suited (serving static content). Wikipedia, itself, is an excellent example of a statically generated website.
Some notable static site generators
Jekyll3Extensibility, both for general markup and specifically for syntax highlighting, requires Ruby knowledge.
- Written in Ruby
- License: MIT License
- Initial release: 2008
- Stable release: 2023
- Input formats
- Markdown
- Textile template
- Liquid template
- Can load data from
yaml
,json
,csv
,tsv
files.4And use that to generate html snippets that can be embedded in webpages.
- Can load data from
- Others via Converter plugin5E.g., AsciiDoc, Slim etc.
- Supported frontend frameworks
- Themes
- Blogging themes
-
tufte-jekyll
(and others) fortufte-css
6 A CSS theme inspired by Edward Tufte’s books and handouts which, among other things, supports notes in the right margin.
- Syntax highlighting (via Rouge highlighter)
- Support for migration to Jekyll7From Wordpress, Blogger, Medium etc.
Hugo8Extensibility for input formats requires Go knowledge; extensibility for syntax highlighting requires Python knowledge.
- Written in Go
- License: Apache License 2.0
- Initial release: 2013
- Stable release: 2023
- Input formats
- Supported frontend frameworks
- Themes
- Syntax highlighting via Chroma.9 Supports a large number of languages and can be extended by writing a custom Pygments lexer.
- Support for migration to Hugo
Gatsby10 Extensibility, both for general markup (in Markdown) and specifically for syntax highlighting is via remark plugins and requires JavaScript/TypeScript knowledge.
Gatsby is a static site generator built on top of Node.js using React.
- Written in JavaScript, TypeScript
- License: MIT License
- Initial release: 2015
- Stable release: 2022
- Input formats
- React component
exported from a
.js
,.jsx
,.ts
, or.tsx
file. - Markdown
- React component
exported from a
- Supported frontend frameworks
- Themes
Tufte.css
support viagatsby-remark-tufte
plugin11However, the markdown converter it relies on is no longer maintained.
- Syntax highlighting via
gatsby-remark-highlight-code
plugin - Some support for migrating to Gatsby
Next.js10 Extensibility, both for general markup (in Markdown) and specifically for syntax highlighting is via remark plugins and requires JavaScript/TypeScript knowledge.
Netx.js is more than just a static site generator - it a web development framework for React-based web applications, but also includes static website generation.
- Written in JavaScript, TypeScript and Rust
- License: MIT License
- Initial release: 2016
- Stable release: 2023
- Input formats
- React component
exported from a
.js
,.jsx
,.ts
, or.tsx
file. - Markdown
- React component
exported from a
- Supported frontend frameworks
- Themes
- Syntax highlighting support
- There doesn’t seem to be good syntax highlighting support. However, there is some Javascript-based support via Highlight.js.
Sphinx12 Extensibility, both for general markup and specifically for syntax highlighting requires (only) Python knowledge.
Sphinx is a documentation generator written in Python that primarily uses reStructuredText as the input format.
- Written in Python
- License: BSD License
- Initial release: 2008
- Stable release: 2022
- Input formats
- RST13reStructuredText can be extended via custom text roles.
- Supported frontend frameworks
- Themes
- Syntax highlighting via Pygments9 Supports a large number of languages and can be extended by writing a custom Pygments lexer.
Conclusion
When building websites for others, the selection of available themes as well as the ability to migrate content from other platforms is perhaps most important. Hugo and Jekyll are perhaps best suited when it’s unlikely that the website may have some dynamic content.
When it is important to have the option to convert the static website into a dynamic one,14Possibly at a later point. generators based on React such as Gatsby and Next.js might be well-suited.
Sphinx is perhaps best-suited for technical documentation and technical blogs. What it lacks in available themes, it makes up for in ease of extensibility.12 Extensibility, both for general markup and specifically for syntax highlighting requires (only) Python knowledge.
Comments
Comments can be left on twitter, mastodon, as well as below, so have at it.
New post!
— The Weary Travelers blog (@wearyTravlrsBlg) July 2, 2023
A review of static site generating frameworks. A future post will describe our own solution, based on Org-mode, in detail.https://t.co/FVJeUIeAM7
Reply here if you have comments.
Footnotes:
In addition to their implementation language, a major difference is the input format that is supported.
And, thus, not needing to manage state server-side.
Extensibility, both for general markup and specifically for syntax highlighting, requires Ruby knowledge.
And use that to generate html snippets that can be embedded in webpages.
A CSS theme inspired by Edward Tufte’s books and handouts which, among other things, supports notes in the right margin.
From Wordpress, Blogger, Medium etc.
Extensibility for input formats requires Go knowledge; extensibility for syntax highlighting requires Python knowledge.
Supports a large number of languages and can be extended by writing a custom Pygments lexer.
Extensibility, both for general markup (in Markdown) and specifically for syntax highlighting is via remark plugins and requires JavaScript/TypeScript knowledge.
However, the markdown converter it relies on is no longer maintained.
Extensibility, both for general markup and specifically for syntax highlighting requires (only) Python knowledge.
reStructuredText can be extended via custom text roles.
Possibly at a later point.