s2gen - static site generator
When I faced the challenge of choosing a static site generator for this very site, I started with trying most popular solutions. After checking Ruby and Go based generators I realized that I don't really like any of them. Then I stumbled upon JBake - an alternative solution that is written in Java and uses typical Java template engines. It worked fine, so I decided to take it.
I still think that JBake is great. However, there were several annoyances like the absence of the monitor mode and several others. After doing some initial research, I realized that it wouldn't be very difficult to roll out my own JVM-based generator.
The first version of the generator was released on March 24, 2016, and several more releases soon followed. While it's still very basic, I believe it could be useful to some people.
Features
- Parsing content from Markdown files
- Rendering HTML using Freemarker templates
- Project skeleton generation
- Monitoring for file changes
- Adding target="_blank" to external links
- Generating post URLs without html extensions
- Embedded Jetty server for easy development
Quick start
In order to try s2gen
, simply download the latest release here and add s2gen
executable to the PATH
:
S2GEN=/home/user/DevTools/s2gen
PATH=$S2GEN/bin:$PATH
After that, invoke the generator with the -init
flag
$ s2gen -init
s2gen
will generate a skeleton project in the current directory and it can be used as a staring point for your site. Then, simply type the following
$ s2gen
in order to generate HTML files and switch the generator into the monitor mode. The HTTP server will also start on port 8080. If you want to use another port, you can change the property in s2gen.json
.
After navigating the browser to localhost:8080, you should see the following page:
You can also disable the HTTP server with the -noserver
command line option. Alternatively, you can run the generator once without switching to the monitor mode with the -once
option. Finally, to see the complete list of supported options, invoke the generator with the -help
option.
Note that the generated files will be put into the site directory. You can also put there static assets like images or fonts and the generator will not touch them. For more in-depth documentation, check out the the GitHub page