Skip to content

Instantly share code, notes, and snippets.

@opattison
opattison / jekyll-css-yaml-colors.css
Created August 28, 2013 01:11
How to use YAML front matter variables in a CSS file to define colors using variables in Jekyll, using Liquid tags. This example uses HSL colors with hex fallback colors. The goal here is to create standardized CSS with a color palette that can easily be extended to a whole file and maintained easily with only a few variables. The same thing cou…
---
white:
hsl: 'hsla(138, 10%, 98%, 1)'
hex: '#f9fafa'
black:
hsl: 'hsla(138, 16%, 10%, 1)'
hex: '#151e18'
green:
hsl: 'hsla(138, 39%, 54%, 1)'
hex: '#5cb777'
@opattison
opattison / key_with_multiple_lines_preserved.yaml
Last active February 9, 2022 22:39
How to preserve multiple YAML lines with newlines (for example, to pass through a Markdown filter in Jekyll)
# How to preserve multiple YAML lines with newlines (for example, to pass through a Markdown filter in Jekyll)
# via: http://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines
key: |+
Hello.
World.
# Output if processed with Markdown:
# '<p>hello</p><p>world</p>'
@opattison
opattison / figure.rb
Last active March 6, 2021 15:28
HTML <figure> tag Liquid tag plugin for Jekyll. Create figure/img HTML elements with optional classes and captions. This is a YAML-dependent Liquid tag plugin for Jekyll for those who fear link rot. The required bits are alt attributes and <img> tags. A unique feature for this method is a markdownified <figcaption>. This tag allows for optional …
# Title: Figure/image tag plugin for Jekyll
# Author: Oliver Pattison | http://oliverpattison.org
# Description: Create figure/img HTML blocks with optional classes and captions. This is a YAML-dependent Liquid tag plugin for Jekyll for those who fear link rot.
#
# Download/source/issues: https://github.com/opattison/jekyll-figure-image-tag
# Documentation: https://github.com/opattison/jekyll-figure-image-tag/blob/master/README.md
#
# Note: designed specifically for implementations with YAML front matter-based images, captions and alt text.
# Create YAML collections in a post like this:
#
@opattison
opattison / gallery.html
Last active January 21, 2020 08:11
A Jekyll photo gallery sample, using a for loop in liquid and collections in YAML front matter. This is sort of pseudo-code, but is in a working state in this project: https://github.com/opattison/jeancflanagan 2013-08-13
@opattison
opattison / 2016-02-13-example.md
Last active April 25, 2016 20:34
Jekyll srcset imgix implementation with include file, srcset/sizes in config, YAML-provided images, and temporarily assigned variables
title image
example srcset implementation
src alt
/images/example.jpg
Don’t forget alt text.

{% assign image = page.image[0] %} {% include srcset.html %}

@opattison
opattison / atom-git-color-override.less
Last active March 30, 2016 02:53
Custom git override styles for Atom tree view and tabs
// include in user `styles.less` “your stylesheet”
@color-status-modified: hsl(22, 50%, 44%);
@color-status-added: hsl(144, 50%, 35%);
@color-status-ignored: hsl(200, 3%, 55%);
// Custom git override styles for Atom tree view
.tree-view {
.status-modified,
.list-tree li.list-nested-item.status-modified > .list-item {

Chatting with Michael Lee about my [previous post on what Jekyll is and why I use it]({% post_url 2016-03-16-consider-jekyll %}), I realized more should be said about how affordable static sites can be. From my own experience, here are some cost estimates for hosting a small site (in US dollars):

  • GitHub Pages: completely free (fewer Jekyll Ruby plugins allowed than a normal Jekyll deployment, but enables automatic deploying).
  • Amazon S3: starting at $0.03 to a few dollars per month for higher traffic (rate depends on usage). [^1]
  • S3 with Route53 for DNS routing: starting at $0.53 to a few dollars per month.
  • S3, Route53 and CloudFront: starting at $0.70 to a few dollars per month. My own site costs around $1.50 per month with this setup in early 2016.
  • [Shared hosting](https://en.wikipe
@opattison
opattison / jekyll-css-yaml-includes.css
Last active December 21, 2015 21:19
How to include multiple CSS sources in a compiled single CSS file (for example, resets, base styles, project-specific styles) using Liquid includes in Jekyll.
---
# No YAML required. Blank front matter so that CSS files can be included via Liquid templating.
# Make sure that the breaks are included at the start of the file so that Jekyll knows to process the Liquid includes.
---
{% include reset.css %}
{% include base.css %}
{% include project.css %}
@opattison
opattison / Rakefile
Last active December 21, 2015 13:59
A simple "notes" Rakefile based on the Octopress default Rakefile. I created this for a notes project.
require 'stringex'
# rake command that generates a new post and opens in default text editor
desc "Generates a new note"
task :post, :title do |t, name|
if name.title
title = name.title
else
title = get_stdin("Enter a title: ")
end
@opattison
opattison / aws-s3-policy-with-ip-limit.json
Last active December 21, 2015 06:09
AWS S3 bucket with IP limits, for basic development testing on S3.
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AddPermissions",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",