This is the code for the Terragrunt website.
Terragrunt website is built with Jekyll and published on Github Pages from docs
folder on master
branch.
Clone or fork Terragrunt repository.
We provide Dockerfile
and docker-compose.yml
files that can be used for serving the site on docker. To use:
- Start docker.
- Run
docker-compose up
- You can now access the site at
http://localhost:4000
-
Install Ruby. Version 2.4 or above is recommended. Consider using rbenv to manage Ruby versions.
-
Install
bundler
:gem install bundler
-
Go to the
docs
folder:cd docs
-
Install gems:
bundle install
-
Run the docs site locally:
bundle exec jekyll serve
GitHub Pages automatically rebuilds the website from the /docs
folder whenever you commit and push to the master
branch.
We recommend updating the documentation before updating any code (see Readme Driven Development). This ensures the documentation stays up to date and allows you to think through the problem at a high level before you get lost in the weeds of coding.
The Terragrunt website contains Docs collection stored respectively in /docs/_docs
.
When you work with the documentation, it's good to preview the changes. To do that, run project as it is described in Run section.
- A) Change content on the existing page
- B) Add a new page
- C) Remove or rename page
- D) Add custom redirection
- Find page in
_docs
by file name (it's the same as page's title). - Edit content.
- Create a new file in
_docs
. The file's name and title have to be the same. - At the beginning of the file, add:
---
layout: collection-browser-doc # X Cannot be changed
title: Quick start # <--- Change this
categories:
- getting-started # <--- Change this if needed
excerpt: Learn how to start with Terragrunt. # <--- Change page description
tags: ["Quick Start", "DRY", "backend", "CLI"] # <--- Set tags
order: 100 # <--- It sorts the docs on the list
nav_title: Documentation
nav_title_link: /docs/
---
layout
- do not change!title
- document titlecategories
- the document's category. Three categories are in use for now: "getting-started", "features", and "community".excerpt
- description. Try to keep it short.tags
- check other posts to see common tags, but you can set a new as well.order
- it is used to sort the documents within collection.nav_title
- the title displayed above navigation. It's optional and it's recommended to use the same as other files in the collection.nav_title_link
- it is URL. If it is set, thenav_title
becomes a link with a given URL.
- Add content at the end of the file.
- Find page in
_docs
by file name (it's the same as page's title). - Delete page or rename.
To add link to any page, including subpages outside of any collection, you can create a new file in _docs
, and set following content in the file:
---
title: Support
categories: Community
excerpt: Need help?
tags: ["support"]
redirect_to:
- /support
order: 301
---
The navigation sidebar is built in _includes/collection_browser/navigation/_collection_toc.html
.
First, the script groups documents of the given collection by categories. Categories make the uppermost level in the navigation sidebar.
Then, within each category, the script adds documents titles to the navigation under specific categories. Documents are sorted by order
field set in frontmatter section.
Next, headings from each document are being extracted and added to the navigation.
|-- _docs # docs *collection*
|-- _includes # partials
|-- _layouts # layouts
|-- _pages # static pages
| |-- 404 # "404: Not found" page
| |-- cookie-policy # "Cookie Policy" page
| |-- docs # index page for *_docs* collection
| |-- index # home page
| |-- support # "Support" page
|
|-- _posts # Posts collection - empty and not used
|-- _site # website generated by Jekyll
|-- assets # Javascript, Stylesheets, and images
|-- scripts # useful scripts to use in development
| |-- convert_md_to_adoc # contains the command to convert MD files to ADOC
|
|-- Gemfile
|-- _config.yml # Jekyll configuration file
The documentation is implemented as a Jekyll collection and built with Collection Browser.
The index page of the Documentation collection is in: _pages/docs/index.html
and is available under /docs
URL. It uses Collection browser from _includes/collection_browser/browser
which makes the list of docs, adds search input with tag filter and puts navigation sidebar containing collection's categories.
Collection is stored in _docs
folder.
The Documentation collection uses collection browser which requires to setup proper meta tags in the doc file.
- Create a new file in collection folder. Documentation add to the
_docs
.
---
layout: collection-browser-doc
title: CLI options # CHANGE THIS
categories:
- getting-started # CHANGE THIS
excerpt: >- # CHANGE THIS
Terragrunt forwards all arguments and options to Terraform. Learn more about CLI options in Terragrunt.
tags: ["CLI"] # CHANGE THIS
order: 102 # CHANGE THIS
nav_title: Documentation # OPTIONAL
nav_title_link: /docs/ # OPTIONAL
---
- layout - always has to be:
collection-browser-doc
[DO NOT CHANGE] - title - the doc title.
- categories - set one category. Use downcase with dashes, e.g.
getting-started
. - excerpt - the doc description.
- tags - doc tags.
- order - it is use to list documents in the right order. "Getting Started" starts from 100, "Features" starts from 200, and "Community" starts from 300.
- nav_title - the title above navigation. It's optional. It's a link if
nav_title_link
is set. - nav_title_link - it is a URL. If it is set,
nav_link
is transformed to the link.
To add a new collection based on Collection browser, like Documentation collection:
- Add collection to the
_config.yml
:
collections:
my-collection: # --> Change to your collection's name
output: true
sort_by: order
permalink: /:collection/:categories/:title/ # --> You can adjust this to your needs. You can remove ":categories" if your collection doesn't use it.
- Create a folder for collection in root directory, e.g:
_my-collection
(change name) - Add documents to the
_my-collection
folder and set proper meta tags (see: Adding new docs to collections). - Create folder for collection's index page in
_pages
. Use collection name, e.g:_pages/my-collection
. - Add
index.html
file to newly create folder:
---
layout: collection-browser # DO NOT CHANGE THIS
title: Use cases
subtitle: Learn how to integrate Terragrunt with Terraform.
excerpt: Learn how to integrate Terragrunt with Terraform.
permalink: /use-cases/
slug: use-cases
nav_title: Documentation # OPTIONAL
nav_title_link: /docs/ # OPTIONAL
---
{% include collection_browser/browser.html collection=site.use-cases collection_name='use-cases' %}
- Change
title
,subtitle
,excerpt
,permalink
, andslug
in meta tags. - In
include
statement, setcollection
to your collection set in_config.yml
and setcollection_name
.
The Collection Browser is strongly inspired by implementation of guides
on gruntwork.io website.
The Collection Browser's purpose is to wrap Jekyll collection into:
- index page containing ordered list of docs with search form,
- show pages presenting docs' contents, and containing navigation sidebar,
- and build navigation sidebar.
- Add collection to
_config.yml
collections:
my-collection: # --> Change to your collection's name
output: true
sort_by: order
permalink: /:collection/:categories/:title/ # --> You can adjust this to your needs. You can remove ":categories" if your collection doesn't use it.
- Create a folder for collection in root directory:
_my-collection
- Add documents (
.adoc
format is recommended) to the_my-collection
folder. - In each document add:
---
layout: collection-browser-doc # <-- It has to be "collection-browser-doc"
title: CLI options # <-- [CHANGE THIS] doc's title
categories: # <-- [CHANGE THIS] use single category. (Downcase and dashes instead of spaces)
- getting-started
excerpt: >- # <-- [CHANGE THIS] doc's description
Terragrunt forwards all arguments and options to Terraform. Learn more about CLI options in Terragrunt.
tags: ["CLI", "Another tag"] # <-- [CHANGE THIS] doc's tags
order: 102 # <-- [CHANGE THIS] set different number to each doc to set right order
---
- Create
index
page for collection. Create folder with collection name in_pages
:my-collection
- Add
index.html
in_pages/my-collection
:
---
layout: collection-browser # <-- It has to be "collection-browser"
title: Use cases
subtitle: Learn how to integrate Terragrunt with Terraform.
excerpt: Learn how to integrate Terragrunt with Terraform.
permalink: /use-cases/
slug: use-cases
---
{% include collection_browser/browser.html collection=site.my-collection collection_name='my-collection' %}
Adjust meta tags and replace my-collection
with your collection name in {% include ... %}
The Collection Browser needs the index page in _pages
folder. It basically imports browser.html
from _includes/collection_browser
.
Meta tags, like title
, subtitle
, excerpt
, are used by Collection Browser on index page. The index page is then published under URL assigned to permalink
.
The index page displays the list of collection's docs. Clicking on any of them, redirects user to the collection's doc page.
Collections are registered in the _config.yml
file like other typical Jekyll collections.
Additional field used in the configuration is: sort_by: order
. It ensures that collection's documents are displayed in the right order.
The order
is set then in every collection document. For large collections it's recommended to split files into several folders, and then to use 3-digit numbers. So each folder would have reserved range of numbers, like: 100 - 199
, 200-299
, etc. It makes easy to add new documents without overwriting order
fields in other docs.
The Collection Browser uses two layouts:
_layouts/collection-browser.html
- for the index page containing the list of documents_layouts/collection-browser-doc.html
- for the "show" page of collection's doc
All Collection Browser partials are stored in _includes/collection_browser
.
browser.html
- it is the collection's index page_doc-page.html
- is a starting point for collection's document pages (show pages)
Some includes may use partials from _includes
directory. For example, _includes/collection_browser/_cta-section.html
uses _includes/links-n-built-by.html
.
Names of assets used by collection-browser
in assets
folder start with collection-browser
.
Collection Browser's classes in stylesheets starts mostly with cb
, collection-browser
and collection-browser-doc
.
Javascript files used by Collection Browser:
collection-browser_scroll.js
- responsible for the scroll spying in navigation sidebar and sticking this bar at the top of the screen when page is being scrolled.collection-browser_search.js
- responsible for handling text search and tag filters.collection-browser_toc.js
- responsible for opening and closing navigation sidebar on the document page.
The navigation sidebar is built in _includes/collection_browser/navigation/_collection_toc.html
. Read more: Navigation
Recommended format of documents is Github Markdown (.md
). If you use the Markdown format (.md
), and you want to convert to AsciiDoc format, you can do this with Pandoc:
- Create
input.md
file and paste there Markdown content - Run:
$ pandoc --from=gfm --to=asciidoc --wrap=none --atx-headers input.md > output.adoc
- The converted content in
.adoc
format is printed inoutput.adoc
You can use also scripts/convert_md_to_adoc.sh
.
To convert from .adoc
(AsciiDoc) format to Markdown, you need AsciiDoctor and Pandoc.
First, install Asciidoctor:
$ sudo apt-get install asciidoctor
Next, install Pandoc: https://pandoc.org/installing.html
Then you can use script: scripts/convert_adoc_to_md.sh
or use the command:
$ asciidoctor -b docbook input.adoc && pandoc -f docbook -t gfm input.xml -o output.md --wrap=none --atx-headers
In both cases:
- create a file:
input.adoc
, - add content to the file,
- run script or command,
- The output can be found in
output.md
.