Skip to content

xlc-dev/fssg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fssg Logo

fssg

fssg is a POSIX-compliant, lightweight static site generator written entirely in shell. It converts Markdown and HTML files under src/ into a ready-to-deploy dist/ directory, with support for templating, includes, conditionals, pagination, asset hoisting, and more—no external dependencies required beyond standard POSIX utilities.

MIT License POSIX Compliant GitHub Stars


Table of Contents

  1. Features
  2. Prerequisites
  3. Installation
  4. Quick Start
  5. Directory Layout
  6. Command-Line Options
  7. Usage Examples
  8. Advanced Features
  9. License

Features

  • Pure Shell & POSIX-Compliant No runtime dependencies beyond sh, awk, sed, find, cp, etc.

  • Markdown & HTML Support Built-in Markdown-to-HTML parser (headings, lists, tables, bold/italic, links).

  • Templating Global src/template.html with {{title}} and {{content}} placeholders.

  • Includes & Blocks {{ include:foo.html }} and {{ include-block:foo.html param="value" }} for reusable snippets.

  • Conditional Rendering {{ IF_EXT:md }}…{{ ENDIF_EXT }} or {{ IF_PAGE:about.html }} to show/hide content.

  • Post Listings {{ recent-posts count="5" }} and {{ all-posts page_size="10" pagination="true" }} with auto-pagination.

  • Asset Pipeline Copies src/static/ to dist/static/, hoists & de-duplicates <style> and <script> blocks.

  • Developer Conveniences Watch mode (-w), built-in server (-s + mongoose), auto-open (-o), parallel builds (-j).


Prerequisites

  • A POSIX-compliant shell (sh, bash, dash, zsh, etc.)
  • Standard POSIX utilities: awk, sed, find, cp, mkdir, rm, chmod, etc.

Installation

1. Download the script

wget https://github.com/xlc-dev/fssg/raw/main/fssg
chmod +x fssg

Place fssg in your project root.

2. (Optional) Clone repository

If you intend to use the built-in server (-s) you may also want the mongoose binaries:

git clone https://github.com/xlc-dev/fssg.git
cp fssg/fssg ./my-site/
cp -r fssg/mongoose ./my-site/mongoose/
chmod +x ./my-site/fssg

Quick Start

  1. Create your project structure (see next section).

  2. Write content in src/ as .md or .html.

  3. Run the generator:

    ./fssg
  4. Browse output in dist/.


Directory Layout

your-project/
├── fssg                    # shell script
└── src/
    ├── template.html       # global layout ({{title}}, {{content}})
    ├── index.md            # page content (Markdown or HTML)
    ├── about.html          # additional pages
    ├── includes/           # reusable snippets
    │   └── header.html
    └── static/             # CSS, images, fonts, etc.
        └── img/
            └── logo.png
  • template.html: contains your <head>/<body> skeleton.
  • src/*.md|html: content files—Markdown is auto-converted.
  • src/includes/: files for {{ include:… }} and {{ include-block:… }}.
  • src/static/: copied verbatim to dist/static/.

Command-Line Options

./fssg [options]
  • -h Show help and exit
  • -q Quiet mode (errors only)
  • -v Verbose mode (build details)
  • -n No color in output
  • -w Watch src/ for changes and rebuild
  • -s Start local server (requires mongoose/)
  • -o Auto-open browser (requires -s)
  • -j <num> Parallel build jobs (default: 4)

Usage Examples

Basic Page

src/index.md:

{{title: Home}}

# Welcome to My Site

This site is generated by **fssg**.

src/template.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>{{title}}</title>
    <link rel="stylesheet" href="/static/style.css" />
  </head>
  <body>
    {{content}}
  </body>
</html>
./fssg
# → dist/index.html

Include Snippet

src/includes/footer.html:

<footer>
  <p>&copy; 2025 My Company</p>
</footer>

Usage in a page:

{{ include:footer.html }}

Conditional Content

{{ IF_EXT:md }}
<p>This only appears in Markdown-converted pages.</p>
{{ ENDIF_EXT }} {{ IF_PAGE:about.html }}
<p>This is the About page.</p>
{{ ENDIF_PAGE }}

Post Listing

<h2>Latest Posts</h2>
{{ recent-posts count="3" ul_class="posts" li_class="post" show_images="true" }}

Advanced Features

  • Inline Parameters in include-block:
    {{ include-block:card.html title="Hello" }}
    <p>Block content goes here</p>
    {{ endinclude }}
  • Pagination with all-posts:
    {{ all-posts page_size="5" page="2" pagination="true" }}
  • Style & Script Hoisting: All <style> tags move to <head>, <script> tags to end of <body>, deduplicated.

For full details, see the fssg Documentation Website.


License

This project is licensed under the MIT License. See LICENSE for details.

About

fssg - Fast, Simple Static Site Generator.

Topics

Resources

License

Stars

Watchers

Forks