Skip to content

Commit b82bf89

Browse files
authored
Merge pull request #196 from justwriteclick/build
Adds information about templating engines and languages
2 parents 3f658f7 + bc37012 commit b82bf89

6 files changed

Lines changed: 67 additions & 23 deletions

File tree

Gemfile.lock

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ GEM
8888
rb-inotify (~> 0.9, >= 0.9.10)
8989
mercenary (0.4.0)
9090
multipart-post (2.1.1)
91-
nokogiri (1.12.5-x86_64-darwin)
91+
nokogiri (1.13.6-x86_64-darwin)
92+
racc (~> 1.4)
93+
nokogiri (1.13.6-x86_64-linux)
9294
racc (~> 1.4)
9395
nokogumbo (2.0.5)
9496
nokogiri (~> 1.8, >= 1.8.4)
@@ -99,7 +101,7 @@ GEM
99101
pathutil (0.16.2)
100102
forwardable-extended (~> 2.6)
101103
public_suffix (4.0.6)
102-
racc (1.5.2)
104+
racc (1.6.0)
103105
rainbow (3.0.0)
104106
rb-fsevent (0.11.0)
105107
rb-inotify (0.10.1)
@@ -122,6 +124,7 @@ GEM
122124

123125
PLATFORMS
124126
x86_64-darwin-19
127+
x86_64-linux
125128

126129
DEPENDENCIES
127130
html-proofer

_learn/10-templating.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: "Templating and data-based layouts"
3+
layout: learn
4+
image:
5+
path: /images/learn/web-templates.png
6+
thumbnail: /images/learn/web-templates400x225.png
7+
---
8+
9+
Templates can have a couple of different definitions for content, depending on the size. You can make a template for an entire document or for a page. When talking about repositories you can also have a template for a repository.
10+
11+
Template engines within static site generators enable you to use variables or metadata values from other files in the source files that create HTML. Maybe you want to keep the product version value in a metadata file. Or you want to access the domain name the site is built upon, reliably and repeatedly. Template engines integrated with the underlying programming language give access to loops, variables, or functions so that you can enhance your website output.
12+
13+
* Jekyll uses the [Liquid templating engine](https://shopify.github.io/liquid/), originally built by Shopify, written in Ruby. The template language is also called Liquid.
14+
* Hugo has a packaged templating engine similar to Liquid, but Go-based. Read more in [Introduction to Hugo Templating](https://gohugo.io/templates/introduction/).
15+
* Sphinx uses Python for any extensibility you need. I find it helpful to browse through the [Read the Docs Theme](https://github.com/rtfd/sphinx_rtd_theme) to find examples of templating.
16+
17+
## Version values as a use case for templates
18+
19+
For web templates, the data can be substituted at the smallest level possible, the word or character level. A templating engine uses certain characters to indicate that you want to start substituting in other information from a data source. For example, a double curly bracket can show the start of the template insertion point.
20+
21+
When using a templating language like Liquid in Jekyll, you can access the version value from a data file or from a database. Read more in the Liquid documentation about [Iteration](https://shopify.github.io/liquid/tags/iteration/).
22+
23+
The Read the Docs theme for Sphinx uses Python variables to indicate the version, using values from the `conf.py` file for the project and a definition list rather than an unordered list.
24+
25+
A practical example for storing a value for version would be in the `_config.yml` file in a Jekyll project. In this case, you want to output the older versions of the docs site to different base URLs, and there was a product name change from one version to the next.
26+
27+
Take this `_config.yml` file, which is for the current version, where the product is named "Oppogrid" and you want to have /latest/ in the URL:
28+
29+
```
30+
baseurl : /versions-jekyll/latest
31+
productname : Oppogrid
32+
```
33+
34+
The numbered version is 4.2, so this `_config.4.2.yml` file outputs to a /4.2/ URL but this release is the one with the new product name.
35+
36+
```
37+
baseurl : /versions-jekyll/4.2
38+
productname : Oppogrid
39+
```
40+
41+
In this release, `_config.4.1.yml`, the product was named "Opposcale" and all the product name mentions can correctly subsititue in the right value for that release point.
42+
43+
```
44+
baseurl : /versions-jekyll/4.1
45+
productname : Opposcale
46+
```
47+
48+
Any place that your source files contain these template indicators, you can rely on substitution to fill in the values.
49+
50+
Example snippet from a Markdown file with substitutions:
51+
52+
See the [ {{ site.productname }} User Guide]({{ site.baseurl }}user-guide) for more information.
53+
54+
With the first `_config.yml` file, the output would be:
55+
"See the [Oppogrid User Guide](https://annegentle.io) for more information." and the internal cross link would go to the correct version for that site.
56+
57+
## Additional resources
58+
59+
[Learning Liquid](https://www.shopify.com/partners/blog/topics/learning-liquid)
60+
61+
[Sphinx Readthedocs theme documentation](https://sphinx-rtd-theme.readthedocs.io/)

_posts/10-templating.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

images/learn/web-templates.png

36 KB
Loading
21.1 KB
Loading

learn/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: collection
33
permalink: /learn/
44
collection: learn
55
entries_layout: grid
6-
last_modified_at: Sat Jul 28 10:56:38 CDT 2018
6+
last_modified_at: Tue Jun 7 21:15:31 CDT 2022
77
---
88

99
Sphinx, Jekyll, and Hugo, all are static site generators that teams use for web sites and documentation sites. Let's go through setting up a static site generator and a common CICD system with it.

0 commit comments

Comments
 (0)