In this guide, you’ll learn how to contribute to the Dapr docs repository. Since Dapr docs are published to docs.dapr.io, you must make sure your contributions compile and publish correctly.
Before contributing to the Dapr docs:
The Dapr docs handles branching differently than most code repositories. Instead of a main
branch, every branch is labeled to match the major and minor version of a runtime release. For the full list visit the Docs repo
Generally, all of your docs updates should point to docs branch for the latest release of Dapr. The latest release is the default branch [https://github.com/dapr/docs]. For example, if you are fixing a typo, adding notes, or clarifying a point, make your changes into the default Dapr branch.
For any docs changes applicable to a release candidate or a pre-release version of the docs, point your changes into that particular branch. For example, if you are documenting an upcoming change to a component or the runtime, make your changes to the pre-release branch.
Style and tone conventions should be followed throughout all Dapr documentation for consistency across all docs:
Style/Tone | Guidance |
---|---|
Casing | Use upper case only:
|
Headers and titles | Headers and titles must be brief, but descriptive and clear. |
Use simple sentences | Write easy-to-read, scannable sentences. Tip: Skip the formal tone and write as if you were talking directly to the reader. |
Avoid the first person | Instead of first person “I”, “we”, and “our”, use second person “you” and “your”. |
Assume a “new developer” audience | Some seemingly obvious steps to an experienced developer might not be as obvious to a new developer. Give the reader more explicit, thorough instructions. |
Use present tense | Avoid sentences like “this command will install Redis”. Instead, use “This command installs Redis”. |
Diagrams and images are invaluable visual aids for documentation pages. Use the diagram style and icons in the Dapr Diagrams template deck.
The process for creating diagrams for your documentation:
service-invocation-overview.png
.<image>
tag.If you’re creating a new article, make sure you:
Select the topic type below to view a suggested template to help you get started.
Topic type | What is it? |
---|---|
Concept | Answers the question, “What problems does this help me solve?” Avoid repeating the API or component spec; provide more details. |
Quickstart | Provides a “Five minutes to wow” experience. Walk the reader quickly through a feature or API and how it works in a controlled example. |
How-to | Provides a detailed, practical step-by-step through a Dapr feature or technology. Encourage the reader to try with their own scenario, rather than the controlled scenario provided in a quickstart. |
Make sure your contribution doesn’t break the website build. The way Hugo builds the website requires following the guidance below:
File and folder names should be globally unique.
- \service-invocation
- service-invocation-overview.md
Front-matter is what takes regular markdown files and upgrades them into Hugo compatible docs for rendering into the nav bars and ToCs.
Every page needs a section at the top of the document like this:
---
type: docs
title: "TITLE FOR THE PAGE"
linkTitle: "SHORT TITLE FOR THE NAV BAR"
weight: (number)
description: "1+ SENTENCES DESCRIBING THE ARTICLE"
---
---
type: docs
title: "Service invocation overview"
linkTitle: "Overview"
weight: 10
description: "A quick overview of Dapr service invocation and how to use it to invoke services within your application"
---
Weight determines the order of the pages in the left sidebar, with 0 being the top-most.
Front-matter should be completed with all fields including type, title, linkTitle, weight, and description.
title
should be 1 sentence, no period at the endlinkTitle
should be 1-3 words, with the exception of How-to at the front.description
should be 1-2 sentences on what the reader will learn, accomplish, or do in this doc.As per the styling conventions, titles should only capitalize the first word and proper nouns, with the exception of “How-To:”
Hugo ref
and relref
shortcodes are used to reference other pages and sections. These shortcodes also allow the build to break if a page is incorrectly renamed or removed.
For example, this shortcode, written inline with the rest of the markdown page, will link to the _index.md of the section/folder name:
{{% ref "folder" %}}
While this shortcode will link to a specific page:
{{% ref "page" %}}
All pages and folders need to have globally unique names in order for the ref shortcode to work properly. If there are duplicate names, the build will break and an error will be thrown.
To reference a specific section in another page, add #section-short-name
to the end of your reference.
As a general rule, the section short name is the text of the section title, all lowercase, with spaces changed to “-”. You can check the section short name by:
As an example, for this specific section, the complete reference to the page and section would be:
{{% ref "contributing-docs#referencing-sections-in-other-pages" %}}
The following are useful shortcodes for writing Dapr documentation
The markdown spec used by Docsy and Hugo does not give an option to resize images using markdown notation. Instead, raw HTML is used.
Begin by placing images under /daprdocs/static/images
with the naming convention of [page-name]-[image-name].[png|jpg|svg]
.
Then link to the image using:
<img src="/images/[image-filename]" width=1000 alt="Description of image">
Don’t forget to set the alt
attribute to keep the docs readable and accessible.
This HTML will display the dapr-overview.png
image on the overview.md
page:
<img src="/images/overview-dapr-overview.png" width=1000 alt="Overview diagram of Dapr and its building blocks">
Tabs are made possible through Hugo shortcodes.
The overall format is:
[Content for Tab1]
[Content for Tab2]
All content you author will be rendered to markdown, so you can include images, code blocks, YouTube videos, and more.
powershell -Command "iwr -useb https://raw.githubusercontent.com/dapr/cli/master/install/install.ps1 | iex"
wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
brew install dapr/tap/dapr-cli
This example will render to this:
powershell -Command "iwr -useb https://raw.githubusercontent.com/dapr/cli/master/install/install.ps1 | iex"
wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
brew install dapr/tap/dapr-cli
Hugo can automatically embed YouTube videos using a shortcode:
{{% youtube [VIDEO ID] %}}
Given the video https://youtu.be/dQw4w9WgXcQ
The shortcode would be:
{{% youtube dQw4w9WgXcQ %}}
To create a button in a webpage, use the button
shortcode.
An optional “newtab” parameter will indicate if the page should open in a new tab. Options are “true” or “false”. Default is “false”, where the page will open in the same tab.
{{% button text="My Button" link="https://example.com" %}}
My ButtonYou can also reference pages in your button as well:
{{% button text="My Button" page="contributing" newtab="true" %}}
My ButtonYou can customize the colors using the Bootstrap colors:
{{% button text="My Button" link="https://example.com" color="primary" %}}
{{% button text="My Button" link="https://example.com" color="secondary" %}}
{{% button text="My Button" link="https://example.com" color="success" %}}
{{% button text="My Button" link="https://example.com" color="danger" %}}
{{% button text="My Button" link="https://example.com" color="warning" %}}
{{% button text="My Button" link="https://example.com" color="info" %}}
The Dapr Docs supports adding language translations into the docs using git submodules and Hugo’s built in language support.
You can find an example PR of adding Chinese language support in PR 1286.
Steps to add a language:
Open an issue in the Docs repo requesting to create a new language-specific docs repo
Once created, create a git submodule within the docs repo:
git submodule add <remote_url> translations/<language_code>
Add a language entry within daprdocs/config.toml
:
[languages.<language_code>]
title = "Dapr Docs"
weight = 3
contentDir = "content/<language_code>"
languageName = "<language_name>"
Create a mount within daprdocs/config.toml
:
[[module.mounts]]
source = "../translations/docs-<language_code>/content/<language_code>"
target = "content"
lang = "<language_code>"
Repeat above step as necessary for all other translation directories.
Get started by copying and working from one of the Dapr doc templates.