We welcome contributions to the Calico documentation.
Instead of filing a GitHub issue, consider making a PR instead. You are likely to see a much more rapid resolution.
The doc contribution process works as follows.
- Fork the Project Calico repo.
- Create a branch in your fork off of the master branch.
- Give your branch a short but descriptive name.
- Preview your changes to make sure they render as expected. You can either build the site locally or go directly to the "submit a pull request" to build the site with the Project Calico CI/CD system.
- Check for broken links. You can either check for broken links in your local environment or submit a pull request and use the output of the Semaphore job.
- Submit a pull request (PR) against the master branch of the Project Calico repo.
- If you haven't already signed our contributor agreement, GitHub will prompt you to do so (required).
- Request a review from one or more Calico maintainers.
- After getting the approval of at least one Calico maintainer, we ask that you backport the changes in the
master
folder to the folders of the last two releases, if appropriate. - Squash your commits.
- One of the doc repo maintainers will give the PR a final look and then merge it.
- The merge into master will kick off a new build of the live site. You should see your changes on the live site shortly after they are merged.
Important: Ensure that your contribution conforms to the Calico documentation style guide.
Note: For contributions that affect just one page, you can use the Edit this page buttons in the doc site. This allows you to skip a few steps in the process outlined above, but is suitable only for small contributions.
We also encourage you to review Doc site organization, Organizational changes, Link syntax, and RELEASING.md for additional information.
We use GitHub Pages and Jekyll to serve and build our site. While there are several ways to build the site locally, we recommend using our Docker image and the Makefile in the root of the repo. These will allow you to build the site with a single command.
Prerequisite: Docker.
Navigate into the root of the repo and issue the following command from a terminal prompt.
make serve
Once the build completes, it returns a URL as the value of Server address:
. Copy and paste this URL into your browser to view the site.
Note: To view the changes that you've made in the master branch, select nightly from the Releases page.
Pro tip: Jekyll can take a while to render every page. To speed up builds, a supplemental
_config_dev.yml
exists which excludes all directories exceptmaster
. You can include it in your builds as followsjekyll serve --config _config.yml,_config_dev.yml
. Alternatively, you can pass enable it inmake
using the following environment variableDEV=true make serve
.
The Project Calico CI/CD system will generate a site preview automatically with every docs change. An automated response to the PR will indicate "Deploy preview for calico ready!" and provide a link to the preview. If your change is minor and you are not a regular contributor to the project, this method may be easier than building the doc site locally.
Note To view the changes you've made to the master branch, select nightly from the Releases page.
Prerequisite: Docker.
To check for broken links, navigate into the root of the repo and issue the following command from a terminal prompt.
make htmlproofer
The submission of a PR kicks off a continuous integration process which includes a make htmlproofer
command. Any errors from htmlproofer
will cause your PR to fail the continuous integration test, so it's best to run this locally before submitting your PR.
However, you can also run this after submitting your PR and experiencing an htmlproofer
failure from the Semaphore job.
Let's say there's a single commit that makes changes to the master
directory which I want to apply to the v1.5
directory.
-
Generate a diff. A sample command follows which stores the diff in a file called
my-patch.diff
.git diff f35c02fe73e6a64d187ee3f6e9298ca47ded91ab^1 f35c02fe73e6a64d187ee3f6e9298ca47ded91ab > my-patch.diff
-
Apply the diff to the target version directory.
git apply -p2 --directory=v1.5 my-patch.diff
-p2
strips off /master on the front of the paths.--directory=v1.5
adds "v1.5" to the start of the paths.
-
Inspect the results (
git status
,git diff
, etc.) and commit.
The docs are divided into the following sections:
Except for Introduction and Reference, content should be tasked-based. All top-level titles in topics should use an action verb (e.g. configure, enable, modify) with initial caps. For example:
- Configure BGP peers
- Enable overlay networking
- Troubleshoot Calico
- Use calicoctl in a Kubernetes deployment
- Configure egress policy in Kubernetes
Detailed description of components or tabulated configuration information should go in the Reference section.
This page describes Calico and the primary reasons for using it.
Calico can be installed in many different deployments including on-premises and cloud providers. This section includes how to install a standalone Calico cluster for workloads, and how to install Calico on non-cluster hosts. This section covers steps to an "up and running" state. Any task beyond "up and running" should be added to other tabs.
This section contains post-install, task-based content.
This section contains task-based content for networking using the Calico CNI and Calico IPAM.
This section contains task-based content for securing Calico components, workloads, and non-cluster hosts using Calico network policy.
This section contain reference content including full details of APIs and Resources. Add configuration options in one of the per-component references, and list any caveats and considerations when enabling options.
Examples:
- Fully tabulated configuration options per-component
calicoctl
help text- Calico API schema reference (policy, ip pool, etcd)
-
To create a top level splash page for a URL path, name the file
index.md
.If the index.md has child topics, copy the following content and update. All name/keys should be lowercase for consistency. Descriptions should be approximately 50-160 words.
--- title: Install Calico description: Install Calico on nodes and hosts for popular orchestrators, and install the calicoctl command line interface (CLI) tool. canonical_url: '/getting-started/index' show_read_time: false show_toc: false --- {{ page.description }} {% capture content %}{% include index.html %}{% endcapture %} {{ content | replace: " ", "" }}
-
Within the copies of the page in the
master
and previous release directories, add acanonical_url
line below thetitle
line in the metadata of the page. This should contain the absolute path to the page in the current latest directory. Example:canonical_url: 'https://projectcalico.docs.tigera.io/v3.0/getting-started/kubernetes/'
. For more discussion of canonical URLs, refer to the Canonical URLs section.
If you need to delete or rename a directory or file:
-
Ensure that you adjust the side navigation bar to match.
-
Update any
canonical_url
paths that reference the deleted or renamed page. Thecanonical_url
metadata of all previous instances of the page may reference the deleted or renamed page. You must correct these pages to reference the final instance of the page. When you submit your PR,htmlproofer
will flag these errors.-
Deletion example: If you delete a page from the
master
andv3.0
directories, you must update thecanonical_url
path of the page in thev2.6
directory to point to itself. You would also need to update thecanonical_url
paths of any previous instances of the page to point to the copy in thev2.6
directory. This final copy becomes the new canonical copy. -
Renaming example: If you rename a page from the
master
andv3.0
directories, you must update thecanonical_url
path of the page in thev2.6
directory to point to the new path. Also correct any copies in previous directories. -
For more discussion of canonical URLs, refer to the Canonical URLs section.
-
The naming and layout of the side navigation bar is stored in _data/$VERSION/navbars/*
. Jekyll automatically stores information from the _data
directory in an accessible variable called site.data
. The top-level layout (_layout/docwithnav.html
) will iterate through all the files in site.data[version].navbars
to construct the sidebar based on which version is being viewed.
Note: Sidebar paths to index files (see next section) should end in a
/
in the yaml file. Sidebar paths to actual files should not end in a/
in the yaml file.
To link to a page not named index.md
, omit the closing slash. To link to a page named index.md
, include a closing slash. See the following table for some examples.
URL | File path |
---|---|
/getting-started/kubernetes/ |
/getting-started/kubernetes/index.md |
/getting-started/kubernetes/troubleshooting |
/getting-started/kubernetes/troubleshooting.md |
site.baseurl
To create clickable links to other doc site content, use links prefixed with: {{ site.baseurl }}
. For example:
[Get started]({{ site.baseurl }}/getting-started/)
Will render as:
<a href="/v3.8/getting-started/">Getting started</a>
absolute_url
The absolute_url
filter must be used whenever you are not creating a clickable <a href='...'>
element, but instead are showing the user a URL to copy locally. A common example is downloading manifests or showing a user how to kubectl apply -f https://...
them.
For absolute links, use {{ "/path" | absolute_url }}
. For example:
kubectl apply -f `{{ "/manifests/calicoctl.yaml" | absolute_url }}`
Will render as:
kubectl apply -f `https://docs.tigera.io/v3.8/manifests/calicoctl.yaml`
site.url
This renders as the top-level site authority string, without any version prefixes. Use this when you are showing the user a URL to copy, but want to specify the path portion verbatim, without Jekyll adding any page version information. For example, if you need to link to a hard-coded version of a page:
kubectl apply -f `{{site.url}}/v3.4/manifests/calicoctl.yaml`
Will render as:
kubectl apply -f `https://docs.tigera.io/v3.4/manifests/calicoctl.yaml`
Use the following syntax for any link that takes the user outside the docs site; so the link opens in a separate window.
{% include open-new-window.html text='NAME' url='URL' %}
Example
{% include open-new-window.html text='Create an AKS cluster and enable network policy' url='https://docs.microsoft.com/en-us/azure/aks/use-network-policies' %}
Do not include any uppercase letters in your links.
An anchor link for each heading is automatically created. It consists of the title of the heading with each word separated by hyphens. Delete any slashes in the title. For example, to reference a heading titled "Working with the calico/kube-controllers container" on a page located at https://projectcalico.docs.tigera.io/v3.0/reference/kube-controllers/configuration
, you would use the following:
/{{page.version}}/reference/kube-controllers/configuration#working-with-the-calicokube-controllers-container
Because the documentation site includes content for past versions as well as the latest version, it contains many duplicate pages. When Google indexes the site, it needs to know which copy we prefer. We use jekyll-seo-tag to add canonical URLs to each page. This helps us to ensure that the latest copy of the page comes up first when people search for information via Google.
Each page should include a canonical_url
tag that contains the absolute path to the latest copy of the page, even if the latest copy is the page itself.
You should not need to modify the canonical_url
metadata unless you are adding, deleting, or renaming a page.
Our site adds a copy button to each code block by default. To ensure that readers can copy and paste the code successfully, follow the Code samples recommendations in the DOC_STYLE_GUIDE.
To modify the default behavior for code samples that should not be copied, such as responses, append {: .no-select-button}
. An example follows.
Successfully created 8 resource(s)
{: .no-select-button}
See RELEASING.md