Questions tagged [metalsmith]

Metalsmith is an extremely simple, pluggable static site generator.

Overview

Metalsmith is a pluggable static site generator.
All its is handled by plugins. You simply chain them together.

Example for a simple blog :

Metalsmith(__dirname)
  .use(markdown())
  .use(templates('handlebars'))
  .build();

Here is a list of the available plugins :

  • AUTOPREFIXER : Automatically add vendor prefixes to CSS.
  • ASSETS : Include static assets in your build.
  • BRANCH : Run separate metalsmith pipelines on selected files.
  • BUILD DATE : Add a build date, for things like feeds or sitemaps.
  • CLEAN SCRIPT : Generate a script to cleanup the build directory, if you are adding more than just Metalsmith files.
  • COLLECTIONS : Group files together, like blog posts. That way you can loop over them to generate an index, or add 'next' and 'previous' links between them.
  • COFFEE : Compile CoffeeScript files to Javascript.
  • COPY : Copy and rename files.
  • DRAFTS : Hide any files marked as drafts.
  • ENCODE HTML : Easily encode HTML entities in any HTML file by surrounding target code in triple backticks.
  • EXCEPT : Omit attributes from each file's metadata.
  • EXCERPTS : Extract the first paragraph from the beginning of any Markdown file.
  • FILE METADATA : Add metadata on files based on a pattern
  • FINGERPRINT : Insert a hash of the content into the file name.
  • GULPSMITH : Use Gulp plugins in Metalsmith, or Metalsmith as a Gulp plugin. Useful for uploading files, reading less than an entire directory tree, using external front matter, etc.
  • HEADINGS : Extract headings from HTML files and attach them to the file's metadata. Useful for automatically building navigation for a document.
  • IGNORE : Ignore any files that match a pattern.
  • INCLUDE : Make other source files available as properties.
  • LESS : Convert LESS files to CSS.
  • MARKDOWN : Convert Markdown files to HTML.
  • METADATA : Load metadata from JSON or YAML files.
  • MORE : Stores the content before the "more" comment tag in HTML files.
  • ONLY : Filter out attributes from each file's metadata.
  • PAGINATE : A simple plugin that uses metalsmith-collections to create a paginated collection.
  • PERMALINKS : Apply custom permalinks and rename files to be nested properly for static sites, basically converting about.html into about/index.html.
  • PROMPT : Prompt the user for series of answers in the command line and add them to the global metadata.
  • REPLACE : Replace attribute values in each file's metadata.
  • SASS : Convert Sass files to CSS.
  • SHORTCODES : Render wordpress-esque shortcodes via templates.
  • STATIC : Copy public assets into the build directory.
  • STYLUS : Convert Stylus files to CSS.
  • TITLE : Automatically generate a page title from first heading in each file.
  • TEMPLATES : Render any file through a templating engine of your choice.
  • UGLIFY : Uglifies/minifies your JavaScript files
  • WATCH : Watching for file changes and trigger rebuilds.
  • WEBPACK : Bundle CommonJS, AMD and ES6 modules.

Links

59 questions
2
votes
1 answer

Can't make metalsmith-layouts and metalsmith-in-place work

I try to make me a boilerplate with metalsmith using some plugins but I can't make metalsmith-layouts and metalsmith-in-place work together. I tried many things and I succeed to make one of them work but never the second using a template engine (for…
1
vote
1 answer

Bundled assets seem to have a wrong path when using webpack's file-loader

I am new to Webpack and have a hard time melting it together with metalsmith. Currently I have the following folder structure: ├───content // markdown files ├───dist │ ├───assets // contains bundle.js │ │ ├───fonts // contains…
Matthias Güntert
  • 4,013
  • 6
  • 41
  • 89
1
vote
0 answers

metalsmith-in-place gives Template render error: (unknown path)

I have a fairly large Metalsmith project using Nunjucks for templating (i.e. using metalsmith-in-place, which uses jstransformer-nunjucks): const Metalsmith = require('metalsmith'), inplace =…
jhx4mp
  • 21
  • 4
1
vote
1 answer

Create metalsmith collection directly from array via Javascript

I'm generating a static site using Metalsmith's JavaScript API and metalsmith-collections. I have a custom build script which assembles an array dogs which I'd like to use to create a new collection. const Metalsmith =…
jhx4mp
  • 21
  • 4
1
vote
1 answer

How natively to set active menu item with metalsmith?

i got a simple static site with a main navigation. working with the metalsmith generator. Is there a native way to set current menu items active? My current unautomated solution: I just made a workaround like following. A MD file page1.md as source…
André Kelling
  • 1,575
  • 16
  • 23
1
vote
1 answer

Metalsmith Layouts - No Files to Process

I tried to get layouts working following the docs and this example and I can't get layouts to work. I saw that in a github post that I needed to also install jstransformers (which I did) and the handlebars version as well. The layout docs give an…
av0000
  • 1,917
  • 6
  • 31
  • 51
1
vote
0 answers

Using Metalsmith global metadata in twig templates

I'm attempting to use Metalsmith global metadata in my twig templates. I've not found much documentation on using global metadata in templates, regardless of templating language, other than the variable must be referenced as global.KEY so the…
Ben
  • 315
  • 4
  • 19
1
vote
0 answers

nested dependency of npm package broke everything

I've picked up a project that I didn't touch for more than a month and when trying to deploy I found the build was failing. I can replicate the error locally. The project worked fine a month ago, no (direct) dependencies have been updated since…
Mr Peach
  • 1,364
  • 1
  • 12
  • 20
1
vote
0 answers

How to access metadata and front-matter from page when site is generated with gulp?

I am trying to set up Metalsmith process in gulp. Problem is that I don't know how to set up to load metadata from arbitrary number of files of different formats (YAML or JSON) and then use them globally in pages. It works in partials and layouts.…
Vladimir Jovanović
  • 3,288
  • 1
  • 20
  • 27
1
vote
0 answers

Metalsmith: How to use run()?

The docs show a method run(files, fn): Run all of the middleware functions on a dictionary of files and callback with fn(err, files), where files is the altered dictionary. https://www.npmjs.com/package/metalsmith#runfiles-fn How / When should it…
Breaker222
  • 1,334
  • 1
  • 14
  • 23
1
vote
1 answer

Metalsmith and Metalsmith-sass configuration

I am trying to get my metalsmith site to use Sass so I can use Foundation for sites. I have successfully got my site to build and use browser sync but unfortunately my .scss files aren't converting to css. Below is my build.js file and my current…
Just Andy
  • 21
  • 4
1
vote
1 answer

register custom handlebar helper in metalsmith

I am using Metalsmith to generate a static site from a markdown file. The people editing the markdown file will write: {{{link "docs/file.docs"}}} and they expect a link on the site with that file (relative link) The helper is simple, I tested and…
StLia
  • 1,012
  • 2
  • 12
  • 26
1
vote
2 answers

How to insert layout meta info into all files matching a file pattern?

I have lots of markdown source files, which are automatically generated by some data export step. I'm using metalsmith-layouts and have e.g. these lines on top of my handcrafted (not automatically generated) markdown files in order to layout them…
benjist
  • 2,740
  • 3
  • 31
  • 58
1
vote
2 answers

Metalsmith template of template

Is it possible to use templates that extend each other? Say, I have these files: base.html: ...{{{ contents }}} threeColumns.html: --- layout: base.html ---
Ali Ok
  • 716
  • 1
  • 8
  • 23
1
vote
2 answers

Do not convert "Jade include" files to html files

I'm using metalsmith static site generators and building html/css files from jade/sass respectively. When I compile I'm getting the following .scss files as .css files ._scss files are not generated as .css files, but I could include them in the…
Som
  • 270
  • 1
  • 13