Skip to content

Commit a35abb3

Browse files
committed
Update user guide
1 parent 04f235d commit a35abb3

File tree

1 file changed

+255
-3
lines changed

1 file changed

+255
-3
lines changed

userguide/content/en/docs/adding-content/repository-links.md

+255-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,263 @@ The Docsy [docs and blog layouts](/docs/adding-content/content/#adding-docs-and-
1515

1616
This page shows you how to configure these links.
1717

18-
Currently, Docsy supports only GitHub repository links "out of the box". Since GitLab can handle the same link scheme, it should work as well. If you are using another repository such as Bitbucket and would like generated repository links, feel free to [add a feature request or update our theme](/docs/contribution-guidelines/).
18+
Currently, Docsy supports GitHub, Azure DevOps and Gitea repository links "out of the box". If you are using another repository such as Bitbucket and would like generated repository links, you can add a custom template to render the links. Feel free to [add a feature request or update our theme](/docs/contribution-guidelines/).
1919

2020
## Link configuration
2121

22-
There are four site variables you can configure in `hugo.toml`/`hugo.yaml`/`hugo.json` to set up links, as well as one in your page metadata.
22+
There are a few site variables you can configure in `hugo.toml`/`hugo.yaml`/`hugo.json` to set up links, as well as one in your page metadata.
23+
24+
{{< tabpane >}}
25+
{{< tab header="Configuration file:" disabled=true />}}
26+
{{< tab header="hugo.toml" lang="toml" >}}
27+
[params.repo]
28+
type = "github"
29+
url = "https://github.com/google/docsy"
30+
subdir = "userguide"
31+
branch = "release"
32+
project_url = "https://github.com/google/docsy
33+
{{< /tab >}}
34+
{{< tab header="hugo.yaml" lang="yaml" >}}
35+
params:
36+
repo:
37+
type: github
38+
url: https://github.com/google/docsy
39+
subdir: "userguide"
40+
branch: "release"
41+
project_url: "https://github.com/google/docsy
42+
{{< /tab >}}
43+
{{< tab header="hugo.json" lang="json" >}}
44+
{
45+
"params": {
46+
"repo": {
47+
"type": "github",
48+
"url": "https://github.com/google/docsy",
49+
"subdir": "userguide",
50+
"branch"= "release",
51+
"project_url" = "https://github.com/google/docsy
52+
}
53+
}
54+
}
55+
{{< /tab >}}
56+
{{< /tabpane >}}
57+
58+
### `repo.type`
59+
60+
Repo Links are created differently for different git repositories. Currently Docsy supports [GitHub](https://www.github.com), [Azure DevOps](https://azure.microsoft.com/products/devops) and [Gitea](https://about.gitea.com). Specify the type of repository you are using. Supported values are `github`, `azure`, `gitea`.
61+
62+
Other repo types:
63+
64+
* [GitLab](https://about.gitlab.com) can handle the same link scheme as GitHub, so you can use `type: gitlab`.
65+
* [Forgejo](https://forgejo.org) is a fork of gitea and uses the same link schem as gitea, so you can use `type: gitea`.
66+
* To use a **custom repository type**
67+
* define `type: custom` in your configuration and
68+
* place a custom template in your project at `layouts/partials/repo-links-custom.html` which will be used to render the links.
69+
Instead of `custom` you can use any type, you like.
70+
71+
### `repo.url`
72+
73+
The URL for your site's source repository. This is used to generate the Edit this page, Create child page, and Create documentation issue links.
74+
75+
### `repo.subdir` (optional)
76+
77+
Specify a value here if your content directory is not in your repo's root directory. For example, this site is in the userguide subdirectory of its repo. Setting this value means that your edit links will go to the right page.
78+
79+
### `repo.branch` (optional)
80+
81+
Specify a value here if you have would like to reference a different branch in the links to your repository like Edit this page or Create project issue.
82+
83+
### `repo.project_url` (optional)
84+
85+
Specify a value here if you have a separate project repo and you'd like your users to be able to create issues against your project from the relevant docs. The Create project issue link appears only if this is set.
86+
87+
It is assumed that the `project_url` points to the same type of git repository as your documentation site.
88+
89+
### Working with git submodules: `path_base_for_subdir` (optional)
90+
91+
Suppose that the source files for all of the pages under `content/some-section`
92+
come from another repo, such as a [git submodule][]. Add settings like these to
93+
the **section's index page** so that the repository links for all pages in that
94+
section refer to the originating repo:
95+
96+
{{< tabpane >}}
97+
{{< tab header="Front matter:" disabled=true />}}
98+
{{< tab header="toml" lang="toml" >}}
99+
+++
100+
title = "Some super section"
101+
[cascade.repo]
102+
url = "https://github.com/some-username/another-repo/"
103+
subdir = "docs"
104+
path_base_for_subdir = "content/some-section"
105+
106+
+++
107+
{{< /tab >}}
108+
{{< tab header="yaml" lang="yaml" >}}
109+
---
110+
title: Some super section
111+
cascade:
112+
repo:
113+
url: https://github.com/some-username/another-repo/
114+
subdir: docs
115+
path_base_for_subdir: content/some-section
116+
117+
---
118+
{{< /tab >}}
119+
{{< tab header="json" lang="json" >}}
120+
{
121+
"title": "Some super section",
122+
"cascade": {
123+
repo: {
124+
"url": "https://github.com/some-username/another-repo/",
125+
"subdir": "docs",
126+
"path_base_for_subdir": "content/some-section"
127+
}
128+
}
129+
}
130+
{{< /tab >}}
131+
{{< /tabpane >}}
132+
133+
As an example, consider a page at the path
134+
`content/some-section/subpath/some-page.md` with `branch` globally set to
135+
`main`. The index page settings above will generate the following edit link for
136+
`some-page.md`:
137+
138+
```nocode
139+
https://github.com/some-username/another-repo/edit/main/docs/subpath/some-page.md
140+
```
141+
142+
To make it clear, without the settings in the sections index page, the Edit link would be:
143+
144+
```nocode
145+
https://github.com/google/docsy/edit/main/userguide/content/some-section/subpath/some-page.md
146+
```
147+
148+
If you only have a single page originating from another repo, then omit the
149+
`cascade` key and write, at the top-level, the same settings as illustrated
150+
above.
151+
152+
If you'd like users to create project issues in the originating project repo as well,
153+
then also set `project_url`, something like this:
154+
155+
{{< tabpane >}}
156+
{{< tab header="Front matter:" disabled=true />}}
157+
{{< tab header="toml" lang="toml" >}}
158+
+++
159+
160+
[cascade.repo]
161+
url = "https://github.com/some-username/another-repo/"
162+
project_url = "https://github.com/some-username/another-repo/"
163+
164+
+++
165+
{{< /tab >}}
166+
{{< tab header="yaml" lang="yaml" >}}
167+
---
168+
169+
cascade:
170+
repo:
171+
url: &repo https://github.com/some-username/another-repo/
172+
project_url: *repo
173+
174+
---
175+
{{< /tab >}}
176+
{{< tab header="json" lang="json" >}}
177+
{
178+
179+
"cascade": {
180+
"repo": {
181+
"url": "https://github.com/some-username/another-repo/",
182+
"project_url": "https://github.com/some-username/another-repo/"
183+
}
184+
}
185+
186+
}
187+
{{< /tab >}}
188+
{{< /tabpane >}}
189+
190+
{{% alert title="Tip" %}}
191+
Please note that the YAML code fragment makes use of [Yaml anchor](https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/). Use of Yaml anchors is optional, but it helps keep the settings [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself).
192+
{{% /alert %}}
193+
194+
The `path_base_for_subdir` setting is a regular expression, so you can
195+
use it even if you have a site with [multiple languages][] for example:
196+
197+
{{< tabpane >}}
198+
{{< tab header="Front matter:" disabled=true />}}
199+
{{< tab header="toml" lang="toml" >}}
200+
+++
201+
202+
path_base_for_subdir = "content/\w+/some-section"
203+
204+
+++
205+
{{< /tab >}}
206+
{{< tab header="yaml" lang="yaml" >}}
207+
---
208+
209+
path_base_for_subdir: content/\w+/some-section
210+
211+
---
212+
{{< /tab >}}
213+
{{< tab header="json" lang="json" >}}
214+
{
215+
216+
"path_base_for_subdir": "content/\w+/some-section"
217+
218+
}
219+
{{< /tab >}}
220+
{{< /tabpane >}}
221+
222+
In situations where a page originates from a file under a different name, you
223+
can specify `from` and `to` path-rename settings. Here's an example where an
224+
index file is named `README.md` in the originating repo:
225+
226+
{{< tabpane >}}
227+
{{< tab header="Front matter:" disabled=true />}}
228+
{{< tab header="toml" lang="toml" >}}
229+
+++
230+
231+
[repo]
232+
url = "https://github.com/some-username/another-repo/"
233+
subdir = "docs"
234+
235+
[repo.path_base_for_github_subdir]
236+
from = "content/some-section/(.*?)/_index.md"
237+
to = "$1/README.md"
238+
239+
+++
240+
{{< /tab >}}
241+
{{< tab header="yaml" lang="yaml" >}}
242+
---
243+
244+
repo:
245+
url: https://github.com/some-username/another-repo/
246+
subdir: docs
247+
path_base_for_github_subdir:
248+
from: content/some-section/(.*?)/_index.md
249+
to: $1/README.md
250+
251+
---
252+
{{< /tab >}}
253+
{{< tab header="json" lang="json" >}}
254+
{
255+
256+
"repo": {}
257+
"url": "https://github.com/some-username/another-repo/",
258+
"subdir": "docs",
259+
"path_base_for_subdir": {
260+
"from": "content/some-section/(.*?)/_index.md",
261+
"to": "$1/README.md"
262+
}
263+
},
264+
265+
}
266+
{{< /tab >}}
267+
{{< /tabpane >}}
268+
## GitHub configuration (deprecated)
269+
270+
{{% alert title="Deprecation note" color="warning" %}}
271+
These setting are deprecated. Use the params described in [Link Configuration][] instead.
272+
273+
[Link Configuration]: #link-configuration
274+
{{% /alert %}}
23275

24276
### `github_repo`
25277

@@ -361,7 +613,7 @@ Class names using the `--KIND` suffix were deprecated as of [v0.9.0].
361613

362614
To have page-source metadata displayed at the bottom of documentation pages and
363615
blog posts, set the `GitInfo` configuration parameter to `true`, and ensure that
364-
`params.github_repo` is defined.
616+
`params.repo.url` is defined.
365617

366618
A last-modified page note looks something like this:
367619

0 commit comments

Comments
 (0)