ExpressJS Middleware uses redis to store/manage meta data for site pages


This is a very simple meta tag manager for your ExpressJs app. The middleware uses redis to store and manage meta tag data for your webpages.

Install with:

npm install express-meta-tags
  • Bulk import meta tag data into redis from csv or url (think google doc spreadsheet)
  • Meta tag data keyed by req.url and loaded on each request
  • Use RegEx to control which urls should have meta tag data fetched
  • Support for rel="canonical"


/about-us,,"All About Us","A bunch of info about who we are"
/,,"The Home Page","Description of the home page"
node bin/bulk-load.js -h -p 6379 --prefix meta-tags meta-tags.csv


node bin/bulk-load.js -h -p 6379 --prefix meta-tags ""
  • Make sure you put any urls in quotes
  • Your CSV must have a header row. The header values will be uppercased before they are stored in redis.
        ignore: /^\/(images|js|css)/,
        redis: {
            host: app.settings.redishost || 'localhost',
            port: app.settings.redisport || '6379',
            opts: {}
    /* if you want it available in your view */
    app.use(function(reqresnext) {
        res.locals.meta = req.meta;

##Use your meta tag data in your template

- var title       = (typeof meta.TITLE       !== "undefined") ? meta.TITLE       : 'A default title';
- var description = (typeof meta.DESCRIPTION !== "undefined") ? meta.DESCRIPTION : 'A default description';
- var canonical   = (typeof meta.CANONICAL   !== "undefined") ? meta.CANONICAL   : false;

title #{title}
meta(name="description", content="#{description}")
- if (canonical)
    link(rel="canonical", href="#{canonical}")



a string to prepend to the redis key. The redis key looks like this: <prefix>:<req.url>. for example,


would act as the key for the meta data for the /about-us url


a string which will be the key in the req obj. Essentially, req[opts.namespace] = metaTagData.


a regular expression. If opts.accept.test(req.url) is true, meta tag data will be fetched using the key: <prefix>:<req.url>


a regular expression. If opts.ignore.test(req.url) is true, meta tag data will not be fetched. If opts.accept is defined, opts.ignore will only be in effect if opts.accept.test(req.url) is false.


a js object containing the connection config for redis (uses: node-redis)

        host: <host>,
        port: <port>,
        opts: <node-redis opts>

You can get your meta data into redis using bin/bulk-load.js.

Import a csv containing meta tag data for urls.

Usage: node ./bulk-load.js <file|"url">

*note: if using a url - be sure to put quotes around it.

-p, --port    redis port                               [default: 6379]
-h, --host    redis host                               [default: "localhost"]
-a, --prefix  prefix redis key to namespace your data  [default: "meta-tag"]