npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

html-inject-meta

v3.0.0

Published

Stream meta tags into html

Readme

html-inject-meta

Stream meta tags into html

Build Status npm version Dependency Status Semistandard Style unstable

Introduction

Add metadata tags to a stream of html so that it looks pretty when you share it. See: indexhtmlify#5.

Installation

$ npm i html-inject-meta 

Usage

html-inject-meta is designed to just work without much configuration, but allows overrides when necessary. The input must be valid html containing head and title tags. Insertion of the meta tags is not idempotent. Used without any arguments, the command line version looks for the nearest package.json. For example:

$ html-inject-meta < input.html

Given package.json:

{
  "name": "html-inject-meta",
  "description": "Stream meta tags into html",
  "author": "Ricky Reusser"
}

and given a minimal html input

<!doctype html>
<html>
  <head>
    <title>-</title>
  </head>
  <body>
  </body>
</html>

it produces the output:

<!doctype html>
<html>
  <head>
    <title>html-inject-meta</title>
    <meta name="application-name" content="html-inject-meta">
    <meta name="subject" content="Stream meta tags into html">
    <meta name="abstract" content="Stream meta tags into html">
    <meta name="twitter:title" content="html-inject-meta">
    <meta name="description" content="Stream meta tags into html">
    <meta name="twitter:description" content="Stream meta tags into html">
    <meta name="author" content="Ricky Reusser">
    <meta name="twitter:creator" content="Ricky Reusser">
    <meta property="og:title" content="html-inject-meta">
    <meta property="og:description" content="Stream meta tags into html">
    <meta property="article:author" content="Ricky Reusser">
  </head>
  <body>
  </body>
</html>

If you don't want to pollute your package.json with metadata for sharing, you can override the defaults by adding a html-inject-meta field to your package.json, e.g:

{
  "name": "html-inject-meta",
  "description": "My npm package description",
  "author": "Ricky Reusser",
  "html-inject-meta": {
    "name": "My html-inject-meta demo",
    "description": "Here's a neat demo",
    "url": "http://html-inject-meta.github.io",
    "author": "Ricky Reusser",
    "image": "http://rawgit.com/rreusser/html-inject-meta/master/images/screenshot.png"
  }
}

Even better, use it with indexhtmlify:

$ browserify index.js | indexhtmlify | html-inject-meta > index.html

To override the nearest package.json with your own input JSON:

$ html-inject-meta --input=mydata.json < input.html

You can disable json input with --no-input and instead specify fields on the command line:

$ html-inject-meta --no-input --title="My page!" --description="A description..." --author="My Name" < input.html

If you need further customization or more specificity, look in the code to see the precise logic. PRs with improvements are welcome!

API

require('html-inject-meta')([data])

Returns a transform stream that applies to a stream of html the changes specified in data. The format of data identically matches the format of package.json that is read by the command line version, including the optional html-inject-meta field.

NB: My only use-case for this module is for building static pages. I've done my best to escape entities so that scrapers handle the meta tags well. Escaping via the entities module is too strong so that entities show up in the scraped data. Instead I've escaped &amp;, &quot;, &lt; and &gt; which should provide basic sanitization, but you should exercise caution if passing end-user data through to a publicly distributed page. I'm not willing to assert that malicious injection is absolutely impossible. But realistically it seems fine to me and not like the intended use case anyway. I mean why would you construct your own malicious package.json? I just feel like it's important to be transparent about this. Please don't hesitate to file an issue or PR with any issues or concerns.

See also

This module is heaviliy inspired by and works great with indexhtmlify. Many thanks to Dima Yv for the initial inspiration.

License

© 2016 Ricky Reusser. MIT License.