Foundation for Emails
Foundation for Emails, currently at stable version 2.5.1, is a robust open-source framework designed for building responsive HTML emails that render consistently across various email clients, including challenging ones like Outlook. Originally known as Ink, it transitioned to a Sass-based codebase with its 2.0.0 release, incorporating the Inky templating language, which simplifies email layout by converting custom HTML tags into complex, client-compatible table structures. While releases were infrequent for several years, recent activity (v2.3.0, v2.4.0, v2.5.0, v2.5.1 between 2022-2024) indicates a more active maintenance phase. Its key differentiators include comprehensive testing across email clients, the Inky templating system, and support for both Node.js-based build workflows (via a template stack) and integration into Ruby on Rails projects via a dedicated gem.
Common errors
-
Error: Node Sass version X is incompatible with ^4.0.0.
cause Using an outdated or incompatible version of `node-sass` or `gulp-sass` after Foundation for Emails migrated to Dart Sass in v2.4.0.fixUpdate `gulp-sass` to a version compatible with Dart Sass (e.g., `gulp-sass@5.0.0` or newer), and ensure `sass` (Dart Sass) is installed as a dependency instead of `node-sass`. You may need to remove `node-sass` from `package.json` and reinstall dependencies. -
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! foundation-emails-template@x.x.x start: `gulp --tasks-simple`
cause Common build failure in the `foundation-emails-template` due to Node.js version incompatibility or issues with `gulp` setup, particularly after long periods without updates.fixVerify you are using a compatible Node.js version (historically Node.js v10.x was recommended for the template). Update global `foundation-cli` and `gulp` (`npm install -g foundation-cli gulp`). If problems persist, try deleting `node_modules`, `package-lock.json`, and reinstalling `npm install`. -
ReferenceError: "import" and "export" may only appear at the top level
cause Attempting to use ES Modules syntax (`import`/`export`) in a CommonJS (`require()`) environment, often when a build tool or Node.js version isn't configured for ESM, or when trying to directly import Foundation's internal JS files.fixFoundation for Emails' JavaScript components are typically bundled for client-side inclusion, not designed for direct Node.js ESM/CJS module import. Ensure your build pipeline correctly handles module compilation if you're attempting to customize Foundation's JS. If you're importing external modules, ensure your project supports ESM (e.g., by setting `"type": "module"` in `package.json` or using a transpiler like Babel).
Warnings
- breaking Foundation for Emails v2.0.0 was a complete rewrite, transitioning from the original 'Ink' framework to a Sass-based codebase with the new Inky templating language. Existing Ink projects require significant migration.
- breaking Version 2.4.0 migrated the primary style parser to Dart Sass from Node Sass. This change can break existing build pipelines that relied on Node Sass, especially for users with specific `gulp-sass` or `node-sass` versions.
- gotcha The official email template stack for Foundation for Emails (the recommended way to get started) historically required Node.js no greater than version 10 for stable operation. Using newer Node.js versions might lead to `npm install` or build failures.
- deprecated Foundation for Emails is slated to be merged into the Inky project, with Inky becoming a complete email framework combining templating and styling. The `foundation-emails` repository will continue to receive maintenance but new feature development will occur in Inky v2.
- gotcha JavaScript is generally not supported in most popular email clients for security reasons, and will be blocked. Foundation for Emails includes some minor JavaScript for responsive elements like collapsing navigation, but it's not a general-purpose JS framework for interactive email features.
Install
-
npm install foundation-emails -
yarn add foundation-emails -
pnpm add foundation-emails
Quickstart
git clone https://github.com/foundation/foundation-emails-template my-responsive-email
cd my-responsive-email
# The README suggests Node.js <= 10, but recent updates may support newer.
# If using nvm, uncomment and adjust:
# nvm install 10
# nvm use 10
# Install project dependencies (Gulp, Inky, Sass, etc.)
npm install
# Start the development server with live-reloading
# This will compile your Inky HTML, Sass, and inline CSS
npm start
# To build for production, which inlines all CSS
npm run build
# After `npm start`, edit `src/pages/index.html` (Inky HTML) and `src/assets/scss/app.scss` (Sass)
# Example Inky (in src/pages/index.html or a partial):
/*
<container>
<row>
<columns small="12" large="6">
<h1>Hello, Responsive Email!</h1>
<p>This is a Foundation for Emails template.</p>
<button href="#">Click Me</button>
</columns>
<columns small="12" large="6">
<img src="https://placehold.co/300x200" alt="Placeholder Image">
</columns>
</row>
</container>
*/