Add basic CMS capabilities

to your Swig based views.


Sometimes, when you're done with your new and shiny Swig based app, your client wants to edit some content without paying you big buck$ to do it.

Simply sprinkle your Swig templates with {% cms 'myContentId' %} sections and you're done!


Besides super easy and unobtrusive configuration Swig Tiny-CMS offers:

  • Support for Markdown content sections.
  • File-based persistence.
  • Works with Express 3.x and 4.x
  • Works on Node.js clusters.
  • WYSIWYG Markdown editor.


New tag 'cms' will be registered with your Swig template engine. ContentId string as a parameter is required:

{% cms 'contentId' %}

After adding this tag, editable content section will be available to your authorized users.

Content will be saved in a file with name.

The same content identifiers can be used if you would like to reuse content sections.


This module would not be possible without these awesome dependencies:


npm install swig-tiny-cms --save


Require Swig CMS

var swigCms = require('swig-tiny-cms');

After typical Express and Swig configuration, provide a way for Swig Tiny-CMS to know when user is authorized to edit content via middleware.

app.use(function(req, res, next){

Declare Swig Tiny-CMS options:

var options = {

  //content directory is required
  //should be shared directory when used in cluster
  contentDirectory: __dirname + '/content/',

  //optional array of custom CSS files to be used in editor
  css: ['/css/custom.css'],

  //optional marked.js options
  //more info:
  markedOptions: { breaks: true }


Initialize Swig CMS

swigCms.initialize(swig, app, options);
Fork me on GitHub