Skip to content
Branch: master
Go to file

Latest commit


Failed to load latest commit information.
Latest commit message
Commit time


Grunt task to generate html files.

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-html-generator --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:


The "html-generator" task


In your project's Gruntfile, add a section named html-generator to the data object passed into grunt.initConfig().

  "html-generator": {
    options: {
      root: ".",
      output: "output-file.html",
      minify: false,
    target: {
      files: {
        js: ['js/lib/*.js','js/*.js'],
        css : "css/*.css",
        title : "<%= %>", //shouldn't title be in options?
        head  : ["html/head/*.html"],
        body  : ["html/body/*.html"]

The above code create a html document named "output-file.html" with the content bellow. See Gruntfile.js.

<!DOCTYPE html>

    <meta charset="utf-8" />
    <link type="text/css" rel="stylesheet" href="css/a.css" />
    <link type="text/css" rel="stylesheet" href="css/b.css" />
    <link type="text/css" rel="stylesheet" href="css/c.css" />
    <script type="text/javascript" src="js/lib/a.js"></script>
    <script type="text/javascript" src="js/lib/b.js"></script>
    <script type="text/javascript" src="js/lib/c.js"></script>
    <script type="text/javascript" src="js/a.js"></script>
    <script type="text/javascript" src="js/b.js"></script>
    <script type="text/javascript" src="js/c.js"></script>
    <!-- ./www/html/head.html -->
        html {
            font-family: Arial, Verdana;
            font-size: 16px;
        body {
            color: lightgray;
            background-color: black;

    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
        dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

You can’t perform that action at this time.