All Projects → metalsmith → metalsmith

metalsmith / metalsmith

Licence: MIT License
An extremely simple, pluggable static site generator.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to metalsmith

Metalsmith
An extremely simple, pluggable static site generator.
Stars: ✭ 7,692 (-0.38%)
Mutual labels:  static-site-generator, metalsmith, markdown-to-html
github-flavored-markdown-to-html
Convert markdown to HTML using the GitHub API and some additional tweaks with Python. Comes with full formula support and image compression.
Stars: ✭ 44 (-99.43%)
Mutual labels:  static-site-generator, markdown-to-html
permalinks
A Metalsmith plugin for permalinks.
Stars: ✭ 61 (-99.21%)
Mutual labels:  static-site-generator, metalsmith
Staticman
💪 User-generated content for Git-powered websites
Stars: ✭ 2,098 (-72.83%)
Mutual labels:  static-site-generator, metalsmith
Zola
A fast static site generator in a single binary with everything built-in. https://www.getzola.org
Stars: ✭ 7,823 (+1.32%)
Mutual labels:  static-site-generator, markdown-to-html
directus-metalsmith-snipcart
Lookbook web app with Directus' open source headless CMS, Metalsmith, Vue.js & Snipcart
Stars: ✭ 14 (-99.82%)
Mutual labels:  static-site-generator, metalsmith
hugo-gulp-template
Enhanced template for Hugo projects
Stars: ✭ 28 (-99.64%)
Mutual labels:  static-site-generator
minimal
Website and blog generator for Go, Node.js or Python
Stars: ✭ 94 (-98.78%)
Mutual labels:  static-site-generator
nocms
"NO, You don't need a CMS"
Stars: ✭ 13 (-99.83%)
Mutual labels:  static-site-generator
reslate
Beautiful static documentation for your API
Stars: ✭ 98 (-98.73%)
Mutual labels:  static-site-generator
doctave
A batteries-included developer documentation site generator
Stars: ✭ 349 (-95.48%)
Mutual labels:  static-site-generator
jekyll-skeleton
Scaffolding to start with a Jekyll website
Stars: ✭ 27 (-99.65%)
Mutual labels:  static-site-generator
headings
A Metalsmith plugin that extracts headings from HTML files and attaches them to the file's metadata.
Stars: ✭ 22 (-99.72%)
Mutual labels:  metalsmith
uzu
Uzu is a static site generator with built-in web server, file modification watcher, live reload, i18n, themes, multi-page support, inject external data via local Raku module, and external pre/post command execution.
Stars: ✭ 30 (-99.61%)
Mutual labels:  static-site-generator
pagd
Static site generator in python.
Stars: ✭ 57 (-99.26%)
Mutual labels:  static-site-generator
jschr.io
The static website generator service behind jschr.io.
Stars: ✭ 70 (-99.09%)
Mutual labels:  static-site-generator
nuxt-starter-netlify-cms
Example nuxt + netlify cms project. Nuxt port of Gatsby starter app.
Stars: ✭ 13 (-99.83%)
Mutual labels:  static-site-generator
metalsmith-html-minifier
A Metalsmith plug-in to minify HTML files
Stars: ✭ 23 (-99.7%)
Mutual labels:  metalsmith
nera
A lightweight static site generator
Stars: ✭ 12 (-99.84%)
Mutual labels:  static-site-generator
cards.py
Generate Print-and-Play cards for your board games
Stars: ✭ 16 (-99.79%)
Mutual labels:  static-site-generator

Metalsmith

npm: version ci: build code coverage license: MIT Gitter chat

An extremely simple, pluggable static site generator.

In Metalsmith, all of the logic is handled by plugins. You simply chain them together. Here's what the simplest blog looks like...

Metalsmith(__dirname)
  .use(markdown())
  .use(layouts('handlebars'))
  .build(function (err) {
    if (err) throw err
    console.log('Build finished!')
  })

...but what if you want to get fancier by hiding your unfinished drafts and using custom permalinks? Just add plugins...

Metalsmith(__dirname)
  .use(drafts())
  .use(markdown())
  .use(permalinks('posts/:title'))
  .use(layouts('handlebars'))
  .build(function (err) {
    if (err) throw err
    console.log('Build finished!')
  })

...it's as easy as that!

Installation

NPM:

npm install metalsmith

Yarn:

yarn add metalsmith

Plugins

Check out the website for a list of plugins.

How does it work?

Metalsmith works in three simple steps:

  1. Read all the files in a source directory.
  2. Invoke a series of plugins that manipulate the files.
  3. Write the results to a destination directory!

Each plugin is invoked with the contents of the source directory, and each file can contain YAML front-matter that will be attached as metadata, so a simple file like...

---
title: A Catchy Title
date: 2021-12-01
---

An informative article.

...would be parsed into...

{
  'path/to/my-file.md': {
    title: 'A Catchy Title',
    date: <Date >,
    contents: <Buffer 7a 66 7a 67...>
  }
}

...which any of the plugins can then manipulate however they want. And writing the plugins is incredibly simple, just take a look at the example drafts plugin.

Of course they can get a lot more complicated too. That's what makes Metalsmith powerful; the plugins can do anything you want!

The secret...

We keep referring to Metalsmith as a "static site generator", but it's a lot more than that. Since everything is a plugin, the core library is actually just an abstraction for manipulating a directory of files.

Which means you could just as easily use it to make...

Resources

CLI

In addition to a simple Javascript API, the Metalsmith CLI can read configuration from a metalsmith.json file, so that you can build static-site generators similar to Jekyll or Wintersmith easily. The example blog above would be configured like this:

{
  "source": "src",
  "destination": "build",
  "plugins": [
    { "@metalsmith/drafts": true },
    { "@metalsmith/markdown": true },
    { "@metalsmith/permalinks": "posts/:title" },
    { "@metalsmith/layouts": {} }
  ]
}

You can specify your plugins as either an object or array. Using an array would allow you to specify use of the same plugin multiple times. The above example is then defined as so:

{
  "source": "src",
  "destination": "build",
  "plugins": [
    { "@metalsmith/drafts": true },
    { "@metalsmith/markdown": true },
    { "@metalsmith/permalinks": "posts/:title" },
    { "metalsmith-layouts": true }
  ]
}

And then just install metalsmith and the plugins and run the metalsmith CLI...

metalsmith

# Metalsmith · reading configuration from: /path/to/metalsmith.json
# Metalsmith · successfully built to: /path/to/build

Options recognised by metalsmith.json are source, destination, concurrency, metadata, clean and frontmatter - See "API" section below for usage.

Checkout the static site, Jekyll or Wintersmith examples to see the CLI in action.

If you want to use a custom plugin, but feel like it's too domain-specific to be published to the world, you can include plugins as local npm modules: (simply use a relative path from your root directory)

{
  "plugins": [{ "./lib/metalsmith/plugin.js": true }]
}

API

See API reference at metalsmith.io

Metadata API

Add metadata to your files to access these build features. By default, Metalsmith uses a few different metadata fields:

You can add your own metadata in two ways:

mode

Set the mode of the file. For example, a cleanup.sh file with the contents

---
mode: 0764
---

#!/bin/sh

rm -rf .

would be built with mode -rwxrw-r--, i.e. user-executable.

Troubleshooting

Node Version Requirements

Metalsmith 3.0.0 will support NodeJS versions 12 and higher. Metalsmith 2.4.0 supports NodeJS versions 8 and higher. Metalsmith 2.3.0 and below support NodeJS versions all the way back to 0.12.

Credits

Special thanks to Ian Storm Taylor, Andrew Meyer, Dominic Barnes, Andrew Goodricke, Ismay Wolff, Kevin Van Lierde and others for their contributions!

License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].