basic-ssg
v0.1.9
Published
A Node.js Static Site Generator (SSG). Minimalist, no-framework, and highly configurable.
Maintainers
Readme
Basic-SSG
A Node.js Static Site Generator (SSG). Minimalist, no-framework, and highly configurable.
It uses ejs for templating and gives you full control over the build process via plugins.
Getting Started
Initialize a new project:
mkdir my-site && cd my-site npm install basic-ssg npx basic-ssg initThis creates an example site in
./pagesand apages.config.jsfile.Build:
npx basic-ssg buildThe site is output to
dist-site/by default.Watch Mode:
npx basic-ssg build --watch
Project Structure
pages/: Your site's source.*.ejs: Pages (e.g.,index.ejs,about.ejs).components/: Reusable partials (buttons, headers).custom/: Logic templates (see below).assets/: Images and static files.
pages.config.js: Configuration and plugins.
Configuration
The configuration file allows you to define site metadata and register plugins.
pages.config.js:
import {
ejsPlugin,
tailwindPlugin,
sitemapPlugin,
blogPlugin,
} from "basic-ssg";
export default {
root: "pages",
outDir: "dist-site",
siteUrls: {
"my-page": "https://mysite.com",
},
plugins: [
ejsPlugin(),
tailwindPlugin(),
sitemapPlugin(),
blogPlugin({ templatePath: "pages/**/custom/blog.ejs" }),
],
};Standard Plugins
ejsPlugin: Renders standard.ejspages.tailwindPlugin: Compiles Tailwind CSS.sitemapPlugin: Generatessitemap.xml.blogPlugin: Generates blog posts from markdown files.
Plugins
BasicSSG is powered by a flexible plugin system. For detailed information on how to use the built-in plugins or create your own, see the Plugin Documentation.
Deployment
Since the output is static, you can deploy it to any static hosting service. Bellow are some examples:
NGINX
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ $uri.html =404;
}Express
import express from "express";
const app = express();
app.use(express.static("dist-site", { extensions: ["html"] }));
app.listen(3000, () => console.log("listening on http://localhost:3000"));