Skip to navigation Skip to main content

HAML

HAML, or "HTML abstraction markup language," is a template language that lets you write HTML in a very terse style. The language was initially popular in the Ruby programming language, and was ported to JavaScript.

If you're interested in the HTML shorthand style, the Pug template language is likely a better option for new projects because it is more actively maintained and adopted.

On this page
Eleventy Short Name File Extension npm Package
haml .haml hamljs
Eleventy or Plugin version hamljs version
@11ty/eleventy@0.x hamljs@0.6.x
@11ty/eleventy@1.x hamljs@0.6.x
@11ty/eleventy@2.x hamljs@0.6.x
@11ty/eleventy@3.x and newer N/A
@11ty/eleventy-plugin-haml@1.x hamljs@0.6.x

You can override a .haml file’s template engine. Read more at Changing a Template’s Rendering Engine.

Installation

The haml templating language was moved out of Eleventy core in v3 and now requires a plugin installation.

npm install @11ty/eleventy-plugin-haml

Add to your configuration file:

eleventy.config.js
import hamlPlugin from "@11ty/eleventy-plugin-haml";

export default function (eleventyConfig) {
	eleventyConfig.addPlugin(hamlPlugin);
}
const hamlPlugin = require("@11ty/eleventy-plugin-haml");

module.exports = function (eleventyConfig) {
	eleventyConfig.addPlugin(hamlPlugin);
}

Use more options:

eleventy.config.js
import haml from "hamljs";
import hamlPlugin from "@11ty/eleventy-plugin-haml";

export default function (eleventyConfig) {
	eleventyConfig.addPlugin(hamlPlugin, {
		// Override the `haml` library instance
		eleventyLibraryOverride: haml,
	});
}
const haml = require("hamljs");
const hamlPlugin = require("@11ty/eleventy-plugin-haml");

module.exports = function (eleventyConfig) {
	eleventyConfig.addPlugin(hamlPlugin, {
		// Override the `haml` library instance
		eleventyLibraryOverride: haml,
	});
}

Supported Features

Feature Syntax
🚫 Universal Filters Not yet supported :filterName some text Read more about Filters.