a simple HTML index through stream
Clone or download
Latest commit 5f2299f Aug 25, 2016
Failed to load latest commit information.
.gitignore bam! Jun 19, 2015
.npmignore bam! Jun 19, 2015
LICENSE.md bam! Jun 19, 2015
README.md add option to add a base tag Jul 28, 2016
index.js Add dir option Aug 24, 2016
package.json 1.5.0 Aug 25, 2016
test.js add option to add a base tag Jul 28, 2016




A tiny through stream that returns a bare-bones HTML5 template with an optional <link> and <title> in the head and <script> entry-point in the body.


In html.js

var html = require('simple-html-index')

html({ title: 'hello', entry: 'bundle.js' })

Now run node html.js > index.html and you would end up with a file that looks like this: (after formatting)

<!DOCTYPE html>
<html lang="en">
  <meta charset="utf-8">
  <script src="bundle.js"></script>



stream = html([opt])

Returns a read stream that writes a bare-bones HTML template, with the following optional features:

  • title whether to include a <title> element
  • entry if specified, will add a <script src={{entry}}> element
  • css if specified will add a <link rel="stylesheet" href={{css}}> element
  • favicon if true the favicon.ico request will be suppressed
  • lang the value of the lang attribute in the root <html> element, default 'en'
  • base if specified will add a <base href={{base}}> element

Additional properties

Combine simple-html-index with hyperstream to add additional properties to html. An example how to add an extra <script> tag to the body tag:

const hyperstream = require('hyperstream')
const html = require('simple-html-index')

const htmls = html({ entry: 'static/bundle.js' })
const hs = hyperstream({
  body: { _appendHtml: "<script>console.log('extra tags!')</script>" }



MIT, see LICENSE.md for details.