diff --git a/content/blog/writing-workshop-instructions-with-hugo-variables.md b/content/blog/writing-workshop-instructions-with-hugo-variables.md new file mode 100644 index 0000000..5b8e08e --- /dev/null +++ b/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:{{}}/{{}}.git +git push -u origin master +``` + +Test locally your changes new website by running: + +```sh +hugo server -D +``` + +Tou 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! diff --git a/content/blog/writing-workshop-instructions-with-hugo.md b/content/blog/writing-workshop-instructions-with-hugo.md index 0981048..a73055c 100644 --- a/content/blog/writing-workshop-instructions-with-hugo.md +++ b/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 opensource: - 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 the participant visited and much more! -Install the learn theme: +Install the `learn` theme: ```sh 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 mkdir -p layouts/partials echo '' > 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 @@ -199,4 +199,5 @@ clearly presented. Maintenance and collaboration have been greatly simplified! ![Screenshot of our mini-training](hugo-screenshot.png) -This article is the first of a serie. To be continued. \ No newline at end of file +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.