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
0
votes
1 answer

Metalsmith html template view model binding

I want to create static html pages and bind the content to a javascript object, I know there is a plugin called MetalSmith-layout which binds the value from markdown file to the html, but for my case, the binding values are dynamic, so I cannot…
kitko112
  • 706
  • 1
  • 7
  • 14
0
votes
0 answers

metalsmith-collections via gulpsmith not generating an array of my collection

So, this is admittedly a niche question. It has to do with metalsmith-collections via gulpsmith. I'm adding a blog to a static site and using metalsmith via gulpsmith to do so. I'm having trouble using metalsmith-collections with this setup,…
Donkey Shame
  • 754
  • 3
  • 18
0
votes
1 answer

Get metalsmith, contentful and markdown to work together

I am trying to use Metalsmith to render content from the Contentful platform (using the metalsmith-contentful platform and metalsmith-layout as per the example here). One of my contentful fields is markdown text, so I want to render it as HTML in…
Stev_k
  • 2,118
  • 3
  • 22
  • 36
0
votes
1 answer

How to use underscore's partials in Metalsmith?

I'm using Underscore's templating engine for my Metalsmith website and I'm having a bit of a trouble accessing the footer partial. I'm receiving an error message saying: ReferenceError: footer is not defined How should I call it? What am I doing…
0
votes
1 answer

How to return object or json data to html from handlebars helper

This is my handlebar block in html layout: {{json language}} This is my handlebar helper in my main build.js: handlebars.registerHelper('json', function(language) { var data = { "marathi" : "m", "hindi" : "h", "english" :…
xpark
  • 51
  • 1
  • 11
0
votes
1 answer

Access single object in model using Metalsmith and swig

I have a json data file with multiple objects with named keys in it. { "berlin:" : { "location": "Berlin", "folder": "berlin-2016" }, "seattle" : { "location": "Seattle ", "folder": "seattle-2016" } } In my content file I…
0
votes
1 answer

metalsmith static site generator (with react jsx)

I really want to create static site generator using reacts jsx templates/components. Jekyll and middleman had to be hacked to allow this... But I've discovered http://www.metalsmith.io with plugin:…
user796443
0
votes
1 answer

How to do partials with haml in metalsmith-layouts

How can I use partials with haml in metalsmith-layouts? The docs lists {{> nested/footer }} as a way to use partials in handlebars but I can't work out an equivalent for haml.
msaspence
  • 1,424
  • 2
  • 14
  • 25
0
votes
0 answers

Metalsmith example not working on 1.0 (collections + permalinks)

I found an example online which uses collections and permalinks, the code is like this: Metalsmith(__dirname) .use(collections({ pages: { pattern: 'content/pages/*.md' }, posts: { pattern:…
doup
  • 841
  • 1
  • 9
  • 20
0
votes
1 answer

Why is Markdown rendering

with id's?

I'm using Gulp + Gulpsmith + Metalsmith to create my website. metalsmith_markdown is rendering my HTML as follows: # This is an H1 to

This is an H1

. Why is it rendering that 'id' tag? Why might that be? Here's the part…
Martin Velchevski
  • 874
  • 11
  • 33

0
votes
1 answer

Testing metalsmith plugin that should throw an error using mocha

I'm writing a metalsmith plugin and its associated test suite with mocha. The plugin should throw an exception if it lacks configuration: function plugin(config) { ... return function(files, metalsmith, done) { ... done(new…
Jocelyn LECOMTE
  • 875
  • 1
  • 7
  • 15
-1
votes
1 answer

Handlebar variable inside {{}}?

How can I use a variable containing string 'nav' (from a markdown file) instead of nav (a json file) in: {{#each nav}} {{this}} {{/each}} As I have more than one nav.json file, if I use a variable from the respective markdown file, I want it to…
xpark
  • 51
  • 1
  • 11
-1
votes
1 answer

Metalsmith Blog using FullPage.js

I am trying to set up a simple blog using Metalsmith and the fullPage.js library. At the moment I have a problem where the height of the section divs upon intial loading are roughly 2 times the correct size. Ie. when it initially loads the height…
-2
votes
1 answer

Pure markdown files to html generator

We are trying to convert our documentation files (md files) into a static website. We have been looking at Hugo, Metalsmith and other static site generators. But we feel that all of them are forcing us to add custom markup or a lot of extra…
1 2 3
4