The modular static site generator written in bash (also works with dash and BusyBox ash).
Reads files from the database directory and renders to the generated directory.
- rename the
database.exampledirectory todatabaseand open it - create first page:
- in
pages/sample-page/index.rcis the page definition - in
pages/sample-page/entrypoint.rcare names of the scripts that will be rendered pages/sample-page/assets/square.cssis a sample file for testing thepages__copy_filefunction called fromindex.rcpages/homeis an example home page
- in
- create first post:
- example post directory name is
public_0000001_sample-post, where
publictells thepostsmodule that the post is published
0000001is queue number (you can change it to date e.g.yyyymmddhhmmss)
andsample-postis the link to the post (here:/post/sample-post) - in
posts/public_0000001_sample-post/content.rcis the content of the post - in
posts/public_0000001_sample-post/meta.rcare the post metadata posts/public_0000001_sample-post/assets/post-font.cssis a sample file for testing theposts__copy_filefunction called frommeta.rc- there are empty files in
posts/public_0000001_sample-post/tagsforposts,posts-archandposts-tagsmodules, only file name is processed - empty file
posts/public_0000001_sample-post/arch_2020-12-21has date forposts-archmodule inarch_YYYY-MM-DDformat, only file name is processed - if you want to hide the post change the
public_prefix tohidden_- the post will still be available but will not appear on the list of posts, archives and tags - and if you want to unpublish the post, change the
public_prefix to anything you like, e.g.draft_
- example post directory name is
- create first post plugin:
- everything is described in
posts-plugins/sample-plugin/plugin.rc - remove
posts-plugins/sample-plugin/plugin-disabledto enable this plugin - plugins are displayed below each post on the specific post page
- everything is described in
- put static files in the
staticdirectory and replacedatabase/static/assets/favicon.ico
warning: be careful with dotfiles - if you remove them fromdatabase/static, they may still remain in thegenerateddirectory
this is the intended action to be able to add VCS to this directory - edit files in the
templatesdirectory
you can also add custom templates to this directory (e.g.database/templates/my-template) - edit the settings in
defaults.rc.d - if you want to run something before generating, enter the commands into the
database/generate-hooks/pre-generate.rc
before exiting it looks for thedatabase/generate-hooks/post-generate.rcfile - you can create a
command-stackfile in thedatabasewith a list of the tools you use
you'll be notified if any are missing - run
./generate
if you want to log the output, run./generate > bash-ssg-generate.log 2>&1
The main generate script defines global variables for all modules - if you need, copy this block, paste to the database/defaults.rc.d/defaults.rc and edit. You can change shebang in this file.
Modules reads the default settings from modules/*/defaults.rc.d - do not edit these files. Just copy the chosen config file to the database/defaults.rc.d and edit - files from the database directory has higher priority than configs from modules.
The main settings are defined in database/defaults.rc.d/defaults.rc - do not delete this file.
You can create bin directory and put binaries or links in it (see main generate script).
If you need to execute code early, save it in an lib/generator-init.rc - this file is included right after the generator's basic variables are set.
You can combine static pages with a programming language that can be embedded in HTML (e.g. PHP).
All you need to do is change the option in database/defaults.rc.d/defaults.rc:
defaults__default_file_extension='.php'
and insert the PHP code e.g:
defaults__url_prefix="<?php echo (empty(\$_SERVER['HTTPS']) ? 'http' : 'https').'://'.\$_SERVER['HTTP_HOST']; ?>"
templatestemplate-defaulttemplate-default-nojs
pages- for generating static pagesposts- renders blog postsposts-arch- extension of thepostsmodule which renders lists of posts for specific datesposts-rss- extension of thepostsmodule which renders RSS feedposts-tags- extension of thepostsmodule which renders lists of all tagsstatic- copies static filessitemap- generatessitemap.xmlminify-css,jsandhtmlminifiergzip- compresses all generatedcss,js,htmlandxmlfiles
import-defaults.rc- imports all variables fromdatabase/defaults.rc.dimport-includes.rc- imports all functions frommodules/*/include.rc
- open
modulesdirectory or create one in thedatabasedirectory - create a directory with the module name
- create a
generateorinclude.rcfile- the
generatefile is executed by maingeneratescript (must be executable)
warning: include libraryimport-includes.rcbeforeimport-defaults.rc include.rcis imported bylib/import-includes.rc- put functions that will be used by other modules
warning: never includeimport-includes.rcandimport-defaults.rcininclude.rc- put the names of the used utils (eg. sed or mkdir) in the
command-stack- this file will be checked by the maingeneratescript
- the
- you can create
defaults.rc.d/your-module-name.rcwith module configuration (this file will not be imported automatically)
You need to find a BusyBox binary compiled for Windows. You can find it e.g. here.
Create a bin directory and put the busybox.exe in it.
Follow the instructions below, and then instead of the last step, execute in the command line:
bin\busybox.exe sh generate
By the way, you can check the results of your work by issuing a command:
bin\busybox.exe httpd -f -vv -p 127.0.0.1:8080 -h generated
There isn't. Test it - maybe it will be fast enough for you.