Git Product home page Git Product logo

static-site-generator's Introduction

Static Site Generator

This is a static site generator built using Node.js that takes in Markdown files, processes them and outputs HTML files. The generator takes in a source directory with Markdown files and templates and outputs a destination directory with HTML files.

Prerequisites

Before using this static site generator, you need to have the following software installed:

  • Node.js
  • npm

Project Setup

  1. Clone the repository using the command below:

     git clone https://github.com/augustinewafula/static-site-generator.git
    
  2. Install the dependencies using the command below:

     npm install
    
  3. Run the command below to generate the HTML files:

     npm run build
    
  4. The HTML files will be generated in the dist folder.

Project Structure

  • The src directory contains the Markdown files, templates and navigation file.

  • The src/template directory contains the HTML templates.

  • The dist directory contains the generated HTML files.

Adding Content

To add content to the site, create a new Markdown file in the src/pages directory. The Markdown file should contain a YAML front matter section at the top of the file. The front matter should contain the following fields:

  • template: The name of the template to use for the page. The default template is default.html.

  • title: The title of the page.

It can also contain the following optional fields:

  • date: The date the page was published.

  • author: The author of the page.

Example:

    ---
    template: default.html
    title: My First Blog Post
    date: 02/15/2023
    author: John Doe
    ---

Generating Single Pages

To generate a single page, create a markdown file in the src/pages directory and run the generator with the command npm run build

Generating Blog Pages.

To generate blog pages, create a directory in the src/pages directory and place your markdown files in that directory. The directory name will be used as the blog category. Run the generator with the command npm run build.

Customizing Templates

You can customize the HTML templates by modifying the files in the src/template directory. The generator uses the default.html file as the default template. You can create custom templates by creating a new HTML file in the src/template directory and referencing it in your markdown files.

---
template: custom.html
---

Adding Navigation Links

To add navigation links to the site, add the links to the src/navigation.yml file. The file should contain a list of links with the following fields:

  • name: The name of the link.

  • link: The URL of the link.

Example:

- name: Home
  link: /
- name: About
  link: /about.html
- name: Contact
  link: /contact.html

Conclusion

This static site generator is a simple and flexible solution for generating HTML files from Markdown files. It is highly customizable and can be used to create a wide range of static websites.

Credits

The blog template at https://startbootstrap.com/previews/clean-blog was used for the demo of the static site generator

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

static-site-generator's People

Contributors

augustinewafula avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.