Last active
January 21, 2020 08:11
-
-
Save opattison/6191106 to your computer and use it in GitHub Desktop.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<body> | |
<article class="gallery" role="main"> | |
<section class="photos"> | |
{% for image in page.image %} <!-- Loop through the photos from the YAML frontmatter from an empty Jekyll post --> | |
<figure> | |
<img src="{{ page.image[forloop.index0] }}" alt="{{ page.image-alt[forloop.index0] }}"> <!-- Insert the src, the alt text for each image, using the forloop.index0 liquid helper --> | |
</figure> | |
<figcaption>{{ page.image-caption[forloop.index0] }}</figcaption> <!-- and the figcaption too --> | |
{% endfor %} | |
</section> | |
</article> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
layout: gallery | |
category: photo | |
title: 'Sample gallery of photos generated only using YAML front matter' | |
date: 2013-08-13 10:01 | |
image: | |
- http://farm9.staticflickr.com/8396/8690159972_a1fc390487_b.jpg | |
- http://farm3.staticflickr.com/2807/9108639409_d84348494d_b.jpg | |
- http://farm9.staticflickr.com/8341/8156043146_1b252646e1_b.jpg | |
image-alt: | |
- 'A flower.' | |
- 'Another flower.' | |
- 'A leaf.' | |
image-caption: | |
- 'This is a caption.' | |
- 'This is another caption.' | |
- 'This is yet another caption.' | |
--- | |
# Here is where markdown would go if this were a true .md file. In Jekyll, this would technically *have* | |
# to be a markdown file. This pattern does not require any markdown content, since only front-matter is | |
# actually processed. One could build a large gallery of photos with only YAML front matter. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment