Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

HN Static Site Generator

A simple, elegant static site generator with clean, minimal design. Transform your markdown files into a beautiful, readable website with ease!

License Node

Demo: https://hnstaticgen.netlify.app/

Features

  • 🎨 Clean & Minimal Design - Beautiful, distraction-free reading experience with clean typography
  • πŸ“ Markdown Support - Write in markdown with extended features (tables, footnotes, task lists, code highlighting)
  • πŸš€ Zero Configuration - Works out of the box with sensible defaults
  • πŸ“‘ RSS Feed - Automatic RSS feed generation for your blog
  • πŸ—ΊοΈ Sitemap - SEO-friendly sitemap generation
  • 🏷️ Tags/Categories - Organize your posts with tags
  • πŸ“‹ Draft Posts - Mark posts as drafts to hide them from publication
  • ⚑ Development Server - Built-in server for local preview
  • πŸ‘€ Watch Mode - Auto-rebuild when files change
  • πŸ“¦ Asset Management - Automatic copying of images and other assets
  • πŸ’… Syntax Highlighting - Beautiful code highlighting with highlight.js
  • πŸ“± Responsive Design - Mobile-friendly layout that works on all devices

Quick Start

Installation

git clone https://github.com/heiswayi/hnstaticgen.git
cd hnstaticgen
npm install

Create Your First Post

Create a markdown file in the content/ folder (e.g., my-first-post.md):

---
title: My First Post
description: This is my first blog post
date: "2025-01-15"
tags: ["blog", "first-post"]
draft: false
---

# Hello World!

This is my first post using **HN Static Site Generator**.

Build and Preview

# Build your site
npm run build

# Start development server
npm run serve

# Or do both with watch mode (recommended for development)
npm run dev

Visit http://localhost:8080 to see your site!

Commands

Command Description
npm run build Build the static site
npm run serve Start development server
npm run dev Build, watch for changes, and serve
npm run help Show help information

Configuration

Edit src/config.js to customize your site:

const config = {
  blogName: "Your Blog Name",
  authorName: "Your Name",
  authorDescription: "A brief description about you",
  authorWebsite: "https://yourwebsite.com",
  blogDescription: "Your blog description",
  siteUrl: "https://yourdomain.com", // Important for RSS and sitemap
  dev: {
    postsdir: "./content",      // Where your markdown files are
    outdir: "./public",          // Where to generate the site
    assetsdir: "./assets",       // Where your images/assets are
    port: 8080                   // Development server port
  }
};

Front Matter

Each markdown file should start with front matter:

---
title: Post Title                 # Required
description: Post description     # Required
date: "2025-01-15"               # Required (YYYY-MM-DD format)
tags: ["tag1", "tag2"]           # Optional
draft: false                      # Optional (default: false)
---

Extended Markdown Features

Syntax Highlighting

```javascript function hello() { console.log("Hello, World!"); } ```

Tables

Feature Status
Tables βœ“
Tasks βœ“

Task Lists

  • Completed task
  • Pending task

Footnotes

Text with footnote1

Keyboard Shortcuts

Press [[Ctrl]]+[[S]] to save

Project Structure

hnstaticgen/
β”œβ”€β”€ content/              # Your markdown posts
β”œβ”€β”€ assets/              # Images and other assets (optional)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ cli.js          # CLI interface
β”‚   β”œβ”€β”€ build.js        # Build logic
β”‚   β”œβ”€β”€ config.js       # Configuration
β”‚   β”œβ”€β”€ index.js        # Entry point
β”‚   β”œβ”€β”€ posts.js        # Post generation
β”‚   β”œβ”€β”€ homepage.js     # Homepage generation
β”‚   β”œβ”€β”€ rss.js          # RSS feed generation
β”‚   β”œβ”€β”€ sitemap.js      # Sitemap generation
β”‚   β”œβ”€β”€ assets.js       # Asset copying
β”‚   β”œβ”€β”€ serve.js        # Development server
β”‚   └── watch.js        # File watching
β”œβ”€β”€ public/              # Generated site (git-ignored)
└── package.json

Deployment

GitHub Pages

npm run build
cd public
git init
git add .
git commit -m "Deploy"
git branch -M gh-pages
git remote add origin https://github.com/username/repo.git
git push -u origin gh-pages

Netlify

  1. Connect your repository to Netlify
  2. Set build command: npm run build
  3. Set publish directory: public

Vercel

npm install -g vercel
vercel --prod

See the Deployment Guide post for more options.

Tips

  • Draft Posts: Set draft: true in front matter to hide posts from publication
  • Tags: Add tags to organize your posts by topic
  • Assets: Place images in assets/ folder and reference them in markdown
  • Custom Styles: Edit public/assets/styles/main.css to customize the design
  • RSS Feed: Available at /rss.xml
  • Sitemap: Available at /sitemap.xml

Development

To modify the generator:

  1. Edit files in src/ directory
  2. Run npm run dev to test changes with live reload
  3. The site will auto-rebuild when you save changes

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

Heiswayi Nrird

License

MIT License - see LICENSE file for details

Acknowledgments


Made with ❀️ using Node.js and minimal design principles

Footnotes

  1. Footnote content ↩

About

HN Static Site Generator based on NodeJS

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages