@import email-style
TODO: Document on how to include this in other projects and 3rd-party email providers.
$ bin/setup
$ yarn serve
Now open: http://localhost:4000/email-style-guide/
Running yarn serve
will automatically build assets when they change. To build everything (such as, if you add a new directory), use:
$ yarn build
and then restart Jekyll:
Command+C
$ yarn serve
If you ever remove templates, it's a good idea to clean-up the files generated dist
and docs
with:
$ yarn clean:templates
email-style-guide/
├── src/
│ ├── sass/
│ └── templates/
├── dist/
│ ├── css/
│ └── templates/
├── docs/
│ ├── src/
│ ├── assets/
│ └── templates/
The src
directory is where all source code is stored. Add new templates and styles here.
The dist
directory (short for distribution) is where all code is built. Running yarn build
will generate CSS and HTML templates in this directory.
The docs
directory is where the style-guide documentation is stored.
The docs/assets
directory is where all the style-guide documentation assets are stored. Running yarn build
will generate CSS and JavaScript in this directory.
Running yarn build
will output templates to docs/templates
as well for previewing. In general you shouldn't add new templates here but instead add them under the src
directory.
Add new templates to src/templates
Building
Build email templates with:
$ yarn build
Previewing
After you've added a template, you can preview it with Jekyll. Start the server if you haven't done so already:
$ yarn serve
Say you just added a template in: src/templates/b2b/newsletter-08-2017.html
Now open: http://localhost:4000/email-style-guide/templates/b2b/newsletter-08-2017.html and you should see a preview there.
Optimizing Images
Use TinyPNG to compress images as it often reduces file size by over 50%. For one off images (under 5MB), it's easy to just upload via their website. If you have images >5MB or want to compress several images, you can do so via the API.
- Get a developer account to obtain an API key.
- In Terminal, install Tinify:
sudo gem install tinify
- Put images in a directory.
- Paste the script below in a file named "compress.rb" Replace APIKEY with your API key. Replace the Dir.glob file path with where your files are located. PNG and JPG files are supported, so edit the extension as needed.
require "tinify"
require "fileutils"
Tinify.key = "APIKEY"
FileUtils.mkdir("/Users/hopearmstrong/Desktop/compress/optimized")
Dir.glob("/Users/hopearmstrong/Desktop/compress/*.png") do |filename|
dirname = File.dirname(filename)
basename = File.basename(filename)
optimized_filename = "#{dirname}/optimized/#{basename}"
puts "Shrinking file from: #{filename} to: #{optimized_filename}"
source = Tinify.from_file(filename)
FileUtils.touch(optimized_filename)
source.to_file(optimized_filename)
end
- In Terminal, run the script:
ruby compress.rb
We use HTMLProofer to check the documentation site + templates for broken links, missing images, invalid html, etc.
We currently run these HTMLProofer checks:
Setup the dependencies:
$ bin/setup
And then run:
$ yarn build && yarn test
Test individual templates:
$ bin/test src/templates/example.html
Any errors will appear in red text in Terminal.
Update docs/release_notes.html
with the new version number and some notes about the release.
Update the version number, create a git tag, and push.
$ yarn version
$ git push --tags
This site uses Github Pages and is hosted at https://treehouse.github.io/email-style-guide/. When a change is made to master the templates will be build and updated w/i a few minutes.