# create-html

> create the content of an html file with one function call

Latest version **4.1.0** (published 2017-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install create-html
pnpm add create-html
yarn add create-html
bun add create-html
```

Provides the command `create-html`.

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2017-11-15 |
| First published | 2016-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/create-html) |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 69 |
| Author | sethvincent |
| Maintainers | sethvincent |
| Keywords | html, static, sites, index.html |

## Links

- npm: https://www.npmjs.com/package/create-html
- Repository: https://github.com/sethvincent/create-html
- Homepage: https://github.com/sethvincent/create-html#readme
- Issues: https://github.com/sethvincent/create-html/issues
- npm.io page: https://npm.io/package/create-html

## Dependencies (2)

- [exit](https://npm.io/package/exit.md) ^0.1.2
- [minimist](https://npm.io/package/minimist.md) ^1.2.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 4.1.0 (latest) — 2017-11-15
- 4.0.0 — 2017-09-02
- 3.1.0 — 2017-07-09
- 3.0.0 — 2017-04-26
- 2.0.0 — 2017-04-22
- 1.2.0 — 2017-04-11
- 1.1.0 — 2016-06-08
- 1.0.0 — 2016-06-07

## README

# create-html

Create the content of an html file with one function call.

[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]
[![conduct][conduct]][conduct-url]

[npm-image]: https://img.shields.io/npm/v/create-html.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/create-html
[travis-image]: https://img.shields.io/travis/sethvincent/create-html.svg?style=flat-square
[travis-url]: https://travis-ci.org/sethvincent/create-html
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard
[conduct]: https://img.shields.io/badge/code%20of%20conduct-contributor%20covenant-green.svg?style=flat-square
[conduct-url]: CONDUCT.md

## Install

```
npm install --save create-html
```

## Usage

### `createHTML(options)`

#### `options`
- `title`
- `script`
- `scriptAsync`
- `css`
- `cssAsync`
- `lang`
- `dir`
- `head`
- `body`
- `favicon`

## Examples

Simple example that create an html file with the title `example`:

```js
var html = createHTML({
  title: 'example'
})
```

Example using all options:

```js
var html = createHTML({
  title: 'example',
  script: 'example.js',
  scriptAsync: true,
  css: 'example.css',
  lang: 'en',
  dir: 'rtl',
  head: '<meta name="description" content="example">',
  body: '<p>example</p>',
  favicon: 'favicon.png'
})
```

Create a file with the html contents using the fs module:

```js
var fs = require('fs')
var createHTML = require('create-html')

var html = createHTML({
  title: 'example'
})

fs.writeFile('index.html', html, function (err) {
  if (err) console.log(err)
})
```

Create a stream by pairing this module with [`from2-string`](http://npmjs.com/from2-string):

```js
var fromString = require('from2-string')
var createHTML = require('create-html')

var html = createHTML({
  title: 'example'
})

var stream = fromString(html)
stream.pipe(process.stdout)
```

Pipe content into the html that this module generates by using from2-string and [`hyperstream`](http://npmjs.com/hyperstream)

```js
var fs = require('fs')
var fromString = require('from2-string')
var hyperstream = require('hyperstream')
var createHTML = require('./index')

var html = createHTML({
  title: 'example'
})

var hs = hyperstream({
  'body': fs.createReadStream('some.html')
})

var stream = fromString(html)
stream.pipe(hs).pipe(process.stdout)
```


### Multiple CSS and Javascript Files

Multiple script and stylesheets can be added by sending an array instead of a string:

```js
var html = createHTML({
  css: ['sheet1.css', 'sheet2.css'],
  script: ['script1.js', 'script2.js']
})
```

## CLI

This module comes with a simple command-line tool for creating html files.

Install it globally with `npm i -g create-html`

### Usage:

```
Usage:
  create-html [options]

Options:
  --title, -t        Page title
  --script, -s       JavaScript filename, optional
  --script-async, -a Add async attribute to script tag
  --css, -c          CSS filename, optional
  --favicon, -f      Site favicon
  --lang, -l         Language of content
  --dir, -d          Direction of content
  --head, -H         Content to insert into <head> tag
  --body, -b         Content to insert into <body> tag
  --output, -o       File name. optional. default: stdout
  --help, -h         Show this help message
```

### Example:

```
create-html --title "an example html file"
```

### See also
- [simple-html-index](https://github.com/mattdesl/simple-html-index)

## License
[MIT](LICENSE.md)

---
_Source: https://npm.io/package/create-html · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
