Skip to content

Instantly share code, notes, and snippets.

@shawnbot
Created November 21, 2016 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawnbot/2138bd77d1a685d76a5178464efe96df to your computer and use it in GitHub Desktop.
Save shawnbot/2138bd77d1a685d76a5178464efe96df to your computer and use it in GitHub Desktop.
Jekyll page preview + source

This is a Jekyll-specific way to render HTML source for a given page (in this case, one in a collection) alongside the markup itself without having to duplicate content in includes.

---
---
{% for component in site.components %}
<h1>{{ component.title }}</h1>
<div class="preview">{{ component.content }}</div>
{% capture markup %}
```html
{{ component.content }}
```
{% endcapture %}
<pre class="code">{{ markup | markdownify }}</pre>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment