Browse Source

Merge pull request #4 from nmasse-itix/2019-02-21-update

2019-02-21 update
pull/5/head
Nicolas Massé 7 years ago
committed by GitHub
parent
commit
3055a6e223
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 62
      content/blog/writing-workshop-instructions-with-hugo-variables.md
  2. 9
      content/blog/writing-workshop-instructions-with-hugo.md

62
content/blog/writing-workshop-instructions-with-hugo-variables.md

@ -0,0 +1,62 @@
---
title: "Writing workshop instructions with Hugo, with variables in your content"
date: 2019-02-21T00:00:00+02:00
opensource:
- Hugo
---
This is the second part of my series covering how to
[Write workshop instructions with Hugo"](../writing-workshop-instructions-with-hugo/).
In the first part, we saw how to:
- bootstrap a website with Hugo
- add content, organized in chapters and sections
- customize the look and feel to be suitable for workshop instructions
For this second part, we will add variables to our content so that we can easily
adjust the workshop instructions to different use cases.
One of the most common usage we have for variables is to deliver the same workshop
on different environments. This means URLs, username and passwords change and we
need to adjust our workshop instructions very quicky to match the new environment.
We will continue the example we started in part 1 of this serie: the Hugo mini-training.
Lets pretend that we need to change very often the GIT URL we use in the section named
"Git commit"!
First, edit your `config.toml` and add custom parameters that match your needs.
In our example, we need a GitHub username and repository to change the GIT URL
accordingly.
```ini
[params]
github_username = john
github_repository = hugo-custom-workshop
```
Change the `content/packaging/git-commit.md` to update the commit instructions:
```raw
git remote add origin git@github.com:{{</* param github_username */>}}/{{</* param github_repository */>}}.git
git push -u origin master
```
Test locally your changes new website by running:
```sh
hugo server -D
```
You can now open [localhost:1313/packaging/git-commit/](http://localhost:1313/packaging/git-commit/)
and confirm that variables have been expanded:
```md
git remote add origin git@github.com:john/hugo-custom-workshop.git
git push -u origin master
```
Congratulation, you can now change your `github_username` and
`github_repository` variables at will and see your changes reflect in your
pages!
Stay tuned for the next part of this serie!

9
content/blog/writing-workshop-instructions-with-hugo.md

@ -1,5 +1,5 @@
--- ---
title: "Writing mini-training with Hugo" title: "Writing workshop instructions with Hugo"
date: 2019-02-20T00:00:00+02:00 date: 2019-02-20T00:00:00+02:00
opensource: opensource:
- Hugo - Hugo
@ -58,7 +58,7 @@ suited design for training instructions. It features breadcrumb, navigation
buttons, table of content in the sidebar, checkmark to know which sections buttons, table of content in the sidebar, checkmark to know which sections
the participant visited and much more! the participant visited and much more!
Install the learn theme: Install the `learn` theme:
```sh ```sh
cd hugo-workshop cd hugo-workshop
@ -159,7 +159,7 @@ mkdir -p static/images/
curl https://upload.wikimedia.org/wikipedia/fr/c/cb/Red_hat_logo.png -o static/images/logo.png curl https://upload.wikimedia.org/wikipedia/fr/c/cb/Red_hat_logo.png -o static/images/logo.png
mkdir -p layouts/partials mkdir -p layouts/partials
echo '<img src="/images/logo.png" />' > layouts/partials/logo.html echo '<img src="/images/logo.png" />' > layouts/partials/logo.html
curl "http://www.myiconfinder.com/icon/download/16895e53b6d340dffee1c9b84d90ca94-Redhat.png~10057" -o static/images/favicon.png curl "https://www.redhat.com/profiles/rh/themes/redhatdotcom/favicon.ico" -o static/images/favicon.png
``` ```
# Test locally # Test locally
@ -199,4 +199,5 @@ clearly presented. Maintenance and collaboration have been greatly simplified!
![Screenshot of our mini-training](hugo-screenshot.png) ![Screenshot of our mini-training](hugo-screenshot.png)
This article is the first of a serie. To be continued. In this first part of the series, we presented a very light introduction to
Hugo and its application to workshop instructions. Be sure to read [part 2: Writing workshop instructions with Hugo, with variables in your content](../writing-workshop-instructions-with-hugo-variables/) to discover advanced usages.

Loading…
Cancel
Save