Blogs

EMAIL: info@example.com

OpenSense Labs: Going ultra-minimalist: Metalsmith with Drupal

Going ultra-minimalist: Metalsmith with Drupal
Shankar
Sun, 02/17/2019 – 22:22

A metalsmith sees potential where others might see trash. In his vision, a plastic bag can become a ring, the zipper can turn into a bracelet and brass platters can be metamorphosed into a striking hollow vessel. In the digital spectrum, there’s another Metalsmith which can shape a great web presence for your organisation with its amazing web development capabilities.

A metalsmith working in a room full of metal objects

A combination of Metalsmith and Drupal even more fruitful with Drupal’s spectacular backend that can be used to feed data to all sorts of clients and Metalsmith’s exceptional capabilities as a static site generator.

Forging an understanding

Flowchart showing boxes to explain metalsmith's working principle as a static site generator
Source: Werner Glinka | Twin Cities Drupal Camp 2018

Metalsmith is not aimed at particular project types such as blogs. It supports a wide array of templates and data format options. It offers a simple plug-in architecture and is easy to get started. It uses a modular structure. Its lightweight nature and fewer dependencies make its a magnificent solution.

Metalsmith is an extremely simple, pluggable static site generator – Metalsmith.io

Static site generators create HTML code locally on the developer’s computer and all the required components are stored in a well-structured directory characterised by the strict separation of layout and content. That means a static site generator produces static build files for their deployment to a web server wherein the files are developed from source files. This is exactly the reasoning on which Metalsmith was built. Metalsmith is more than just a static site generator as everything is a plugin and Metalsmith core is an abstraction for manipulation of the file directory. It can be used for building a plethora of use cases like a project scaffolder, or an ebook generator, or even the technical docs.
 
Its working principle is simple. It takes the information from the source files of a source directory and it, then, writes the manipulated information to the files into a destination directory. The manipulations can be the translation of templates, replacement of variables, grouping files, moving files among others.
 
All the manipulations are done by plugins. Only thing Metalsmith has to take care of in its core is to offer an underlying logic of how the manipulations are confronted with and for a defined interface for the plugins. Moreover, source files are, in the nascent stage itself, converted into JavaScript objects so that plugins only do the modifications to the JavaScript objects. Moreover, Metalsmith is divided into a core and several plugins that minimises the intricacy by giving the user complete authority to use only those plugins that are needed and disseminating the task of maintaining the Metalsmith core to the Metalsmith community. Being programmed in Javascript, the need for another language like Python or Ruby is eliminated and it also has a simple plugin-interface thereby offering a simple workflow.

Metalsmith with Drupal

Twin Cities Drupal Camp 2018 had a session that demonstrated how a headless Drupal 8 installation serves content to a local Metalsmith-based static website build process. Drupal 8 turned out to be a fantastic backend CMS for serving data to all kinds of clients. Here, simply put, the local environment is the Metalsmith process uploading anything onto the Github. Once uploaded, Netlify loads it into its own process and publishes it.

Cat-shaped icon at top, green coloured square icon at right, glass with straw at bottom, and a droplet icon containing number 8
Source: Werner Glinka | Twin Cities Drupal Camp 2018

Server data are leveraged for building pages dynamically at build time with the assistance of Metalsmith as the static site generator and the Nunjucks template engine. As a result, the merits of a static website as well as the magnificent backend data governance of Drupal is obtained. Drupal is only utilised for governing content in the backend and is then used to serve the content to the build process through an API.

Conclusion

Metalsmith, along with Drupal’s great prowess in content governance, can be a great solution for building static sites.
 
We believe in empowering the digital firms and making their digital transformation dreams come true with our suite of services.
 
Let us know how do you want us to help you build an astounding web presence at hello@opensenselabs.com

blog banner
 A lot of iron nails piled up

blog image
Sparks of fire whilst a metal being worked on by metalsmith

Blog Type
Is it a good read ?
On