Skip to content

Commit 601fd46

Browse files
authored
Add doc-rooted site example version, update guidance (#2563)
1 parent 8a63d91 commit 601fd46

File tree

9 files changed

+463
-205
lines changed

9 files changed

+463
-205
lines changed

assets/scss/td/_nav.scss

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ $td-link-underline-offsets: (
1111
4: 0.5em,
1212
) !default;
1313

14+
@mixin td-navbar-dropdown-item-icon($fa-icon) {
15+
&::before {
16+
content: fa-content($fa-icon);
17+
font: var(--fa-font-solid);
18+
position: absolute;
19+
left: 0.75rem;
20+
top: 50%;
21+
transform: translateY(-50%);
22+
}
23+
}
24+
1425
.td-navbar {
1526
@extend .navbar;
1627
@extend .navbar-expand;
@@ -137,13 +148,19 @@ $td-link-underline-offsets: (
137148
position: relative;
138149
padding-left: 2.5rem;
139150

140-
&.active::before {
141-
font: var(--fa-font-solid);
142-
content: fa-content($fa-var-check);
143-
position: absolute;
144-
left: 0.75rem;
145-
top: 50%;
146-
transform: translateY(-50%);
151+
&.active {
152+
@include td-navbar-dropdown-item-icon($fa-var-check);
153+
}
154+
155+
&-home {
156+
@include td-navbar-dropdown-item-icon($fa-var-house);
157+
}
158+
159+
&-latest {
160+
font-weight: $font-weight-semibold;
161+
&::after {
162+
content: ' (latest)';
163+
}
147164
}
148165
}
149166
}
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ params:
6060
from_year: 2018
6161
to_year: present
6262
privacy_policy: https://policies.google.com/privacy
63-
archived_version: false
6463
github_repo: https://github.com/google/docsy
6564
github_project_repo: https://github.com/google/docsy
6665
github_subdir: docsy.dev
@@ -169,10 +168,6 @@ security:
169168
# Netlify build env var
170169
- ^(BRANCH|BUILD_ID|COMMIT_REF|CONTEXT|DEPLOY_ID|NETLIFY|PULL_REQUEST|REVIEW_ID)$
171170

172-
sites: &sites
173-
matrix:
174-
languages: [en, fr]
175-
176171
module:
177172
hugoVersion:
178173
extended: true
@@ -185,7 +180,7 @@ module:
185180
# English content for en and as fallback for fr (other pages)
186181
- source: content/en
187182
target: content
188-
sites: *sites
183+
sites: &sites { matrix: { languages: [en, fr] } }
189184
# Mount the repo root *.md files for both languages
190185
- source: ../AGENTS.md
191186
target: content/project/repo/AGENTS.md

docsy.dev/config/_default/params.yaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,30 @@
77
# status: archived # Then fetch include
88

99
version: &docsyVersion 0.14.3-dev
10-
tdBuildId: 006-over-main-d125b877
10+
tdBuildId: 008-over-main-8a63d915
1111
versionLatest: &versionLatest v0.14.2
1212
version_menu: *docsyVersion
1313
version_menu_pagelinks: true
1414
versions:
15+
# - name: '**About**'
16+
# url: /project
17+
# pagelinks: false
18+
# - name: ---
19+
- name: '**Versions**'
1520
- name: Next
1621
version: *docsyVersion
17-
url: https://main--docsydocs.netlify.app
1822
# TODO: use https://next.docsy.dev once it's available
19-
# kind: next
23+
url: https://main--docsydocs.netlify.app
2024
- version: *versionLatest
2125
url: https://www.docsy.dev
22-
# kind: latest
26+
kind: latest
2327
- name: ---
24-
- name: More coming soon...
28+
- name: '**Variant**'
29+
- name: Doc-rooted
30+
url: https://doc-rooted--docsydocs.netlify.app
31+
# TODO: implement /docs/* redirects for doc-rooted site, then drop pagelinks:false
32+
pagelinks: false
33+
kind: home
34+
# - name: Goldydocs
35+
# url: https://example.docsy.dev
36+
# pagelinks: false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
page:
2+
docs: /:sections[1:]/:slug/
3+
section:
4+
docs: /:sections[1:]

docsy.dev/content/en/docs/content/adding-content.md

Lines changed: 52 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ site content root. Hugo automatically applies the appropriate **template** for
7171
that section, depending on which folder the content is in. For example, this
7272
page is in the `docs` subdirectory of the site's content root directory
7373
`content/en/`, so Hugo automatically applies the `docs` template. You can
74-
override this by explicitly specifying a template or content type for a
74+
override this by explicitly specifying a template or [content type][] for a
7575
particular page.
7676

7777
If you've copied the example site, you already have appropriately named
@@ -134,151 +134,53 @@ You can find out much more about how Hugo page layouts work in
134134
[Hugo Templates](https://gohugo.io/templates/). The rest of this page tells you
135135
about how to add content and use each of Docsy's templates.
136136

137-
### Alternative site structure and docs-only sites {#alternative-site-structure}
137+
## Doc-rooted sites <a id="alternative-site-structure"></a>
138138

139-
As noted above, Docsy assumes that (by default) your site has:
139+
Docsy supports documentation-first websites through a **doc-rooted** site
140+
structure, where:
140141

141-
- Home page
142-
- Docs section under `/docs/`
143-
- Blog section under `/blog/`
144-
- Community section under `/community/`
142+
- Documentation pages are published at the site root (`/`) rather than under the
143+
`/docs/` path prefix.
144+
- Page files remain in the `docs` section directory, for example `content/docs/`
145+
or `content/en/docs/`.
145146

146-
The [content type][] of each section determines the layout Hugo uses for that
147-
section.
147+
As a consequence, the `docs` section landing page becomes the site home page. A
148+
doc-rooted site has the following benefits:
148149

149-
[content type]: https://gohugo.io/quick-reference/glossary/#content-type
150-
151-
You may want to have a different site structure for your project while still
152-
making use of Docsy's layouts. A common example is for a **_docs-only_** site,
153-
where all of the pages (including the homepage) use the `docs` layout. In such a
154-
site, you might want to have `/news/` pages formatted with the blog layout.
155-
156-
Since Hugo 0.76, this has become practical without copying layouts to your site,
157-
or having to specify `type: blog` on every single page by making use of
158-
[target specific cascading front matter](https://gohugo.io/content-management/front-matter/#target-specific-pages).
159-
160-
For example, for the `/news/` section, you can specify the following front
161-
matter in the index page which will change the type of the section and
162-
everything below it to "blog":
163-
164-
<!-- markdownlint-disable -->
165-
<!-- prettier-ignore-start -->
166-
{{< tabpane >}}
167-
{{< tab header="Front matter:" disabled=true />}}
168-
{{< tab header="toml" lang="toml" >}}
169-
+++
170-
title = "Latest News"
171-
linkTitle = "News"
172-
173-
[menu.main]
174-
weight = 30
175-
176-
[[cascade]]
177-
type = "blog"
178-
+++
179-
{{< /tab >}}
180-
{{< tab header="yaml" lang="yaml" >}}
181-
---
182-
title: "Latest News"
183-
linkTitle: "News"
184-
menu:
185-
main:
186-
weight: 30
187-
188-
cascade:
189-
- type: "blog"
190-
---
191-
{{< /tab >}}
192-
{{< tab header="json" lang="json" >}}
193-
{
194-
"title": "Latest News",
195-
"linkTitle": "News",
196-
"menu": {
197-
"main": {
198-
"weight": 30
199-
}
200-
},
201-
"cascade": [
202-
{
203-
"type": "blog"
204-
}
205-
]
206-
}
207-
{{< /tab >}}
208-
{{< /tabpane >}}
209-
<!-- prettier-ignore-end -->
210-
<!-- markdownlint-restore -->
150+
- Produces cleaner, documentation-focused URLs (no `/docs/` prefix).
151+
- Avoids the need to create a custom home page using [blocks][] shortcodes or
152+
HTML.
211153

212-
If you want to create a "docs" site, specifying something like the following in
213-
the top level `_index.md` will set all top level sections to be treated as
214-
"docs", except for "news":
154+
To create a doc-rooted site, redefine the `docs` section [permalinks][] in your
155+
[site configuration][] as follows (YAML format shown):
215156

216-
<!-- markdownlint-disable -->
217-
<!-- prettier-ignore-start -->
218-
{{< tabpane >}}
219-
{{< tab header="Front matter:" disabled=true />}}
220-
{{< tab header="toml" lang="toml" >}}
221-
+++
222-
title = "My Wonderful Site"
223-
224-
[[cascade]]
225-
type = "blog"
226-
toc_root = true
227-
228-
[cascade._target]
229-
path = "/news/**"
157+
```yaml
158+
permalinks:
159+
page:
160+
docs: /:sections[1:]/:slug/
161+
section:
162+
docs: /:sections[1:]
163+
```
230164
231-
[[cascade]]
232-
type = "docs"
165+
> [!CAUTION]
166+
>
167+
> Check for root-level URL path conflicts between doc and non-doc sections or
168+
> pages (for example, `/blog/` and `/community/`). If conflicts exist, rename
169+
> the conflicting non-doc paths or keep docs under `/docs/`.
233170

234-
[cascade._target]
235-
path = "/**"
236-
+++
237-
{{< /tab >}}
238-
{{< tab header="yaml" lang="yaml" >}}
239-
---
240-
title: "My Wonderful Site"
241-
242-
cascade:
243-
- type: "blog"
244-
toc_root: true
245-
_target:
246-
path: "/news/**"
247-
- type: "docs"
248-
_target:
249-
path: "/**"
250-
---
251-
{{< /tab >}}
252-
{{< tab header="json" lang="json" >}}
253-
{
254-
"title": "My Wonderful Site",
255-
"cascade": [
256-
{
257-
"type": "blog",
258-
"toc_root": true,
259-
"_target": {
260-
"path": "/news/**"
261-
}
262-
},
263-
{
264-
"type": "docs",
265-
"_target": {
266-
"path": "/**"
267-
}
268-
}
269-
]
270-
}
271-
{{< /tab >}}
272-
{{< /tabpane >}}
273-
<!-- prettier-ignore-end -->
274-
<!-- markdownlint-restore -->
171+
For an example of a doc-rooted variant of this site, see the [Doc-rooted
172+
example][] variant.
275173

276-
Note the addition of `toc_root` here. Setting that to true for a section causes
277-
it to be treated as a separate part of the site, with its own left hand
278-
navigation menu.
174+
[Doc-rooted example]: https://doc-rooted--docsydocs.netlify.app
279175

280-
An example docs-based site that uses this technique can be found at the
281-
[mostly docs](https://github.com/gwatts/mostlydocs/) repo.
176+
> [!NOTE] Legacy _docs-only_ setup
177+
>
178+
> Earlier versions of this page described a docs-only configuration that used a
179+
> front matter `cascade` to set page `type` values.
180+
>
181+
> That approach is no longer supported and can produce incorrect behavior. If
182+
> you are migrating from that setup, remove the `cascade` rule and configure
183+
> doc-rooted permalinks as described above.
282184

283185
## Page front matter
284186

@@ -290,37 +192,31 @@ resources such as images used by the page. You can see a complete list of
290192
possible page front matter in
291193
[Front Matter](https://gohugo.io/content-management/front-matter/).
292194

293-
For example, here's the front matter for this page:
195+
For example:
294196

295197
<!-- markdownlint-disable -->
296198
<!-- prettier-ignore-start -->
297199
{{< tabpane >}}
298200
{{< tab header="Front matter:" disabled=true />}}
299201
{{< tab header="toml" lang="toml" >}}
300202
+++
301-
title = "Adding Content"
302-
linkTitle = "Adding Content"
303-
weight = 1
304-
description = '''
305-
Add different types of content to your Docsy site.
306-
'''
203+
title = "About Docsy"
204+
linkTitle = "About"
205+
description = "Docsy is ..."
307206
+++
308207
{{< /tab >}}
309208
{{< tab header="yaml" lang="yaml" >}}
310209
---
311-
title: "Adding Content"
312-
linkTitle: "Adding Content"
313-
weight: 1
314-
description: >
315-
Add different types of content to your Docsy site.
210+
title: About Docsy
211+
linkTitle: About
212+
description: Docsy is ...
316213
---
317214
{{< /tab >}}
318215
{{< tab header="json" lang="json" >}}
319216
{
320-
"title": "Adding Content",
321-
"linkTitle": "Adding Content",
322-
"weight": 1,
323-
"description": "Add different types of content to your Docsy site.\n"
217+
"title": "About Docsy",
218+
"linkTitle": "About",
219+
"description": "Docsy is ..."
324220
}
325221
{{< /tab >}}
326222
{{< /tabpane >}}
@@ -1029,13 +925,17 @@ To learn more about configuring sitemaps, see [Sitemap Templates][].
1029925
1030926
[alerts]: https://gohugo.io/render-hooks/blockquotes/#alerts
1031927
[attributes]: https://gohugo.io/content-management/markdown-attributes/
928+
[blocks]: /docs/content/shortcodes/#blocks
1032929
[commonmark]: https://spec.commonmark.org/
930+
[content type]: https://gohugo.io/quick-reference/glossary/#content-type
1033931
[Emojis]: https://gohugo.io/quick-reference/emojis/
1034932
[extensions]: https://gohugo.io/configuration/markup/#extensions
1035933
[formats]: https://gohugo.io/content-management/formats/
1036934
[GFM]: https://github.github.com/gfm/
1037935
[Goldmark]: https://github.com/yuin/goldmark
1038936
[Look and Feel]: /docs/content/lookandfeel/
937+
[permalinks]: https://gohugo.io/configuration/permalinks/
1039938
[render hooks]: https://gohugo.io/render-hooks/introduction/
1040939
[shortcodes]: https://gohugo.io/content-management/shortcodes/
940+
[site configuration]: https://gohugo.io/configuration/introduction/
1041941
[Sitemap Templates]: https://gohugo.io/templates/sitemap-template/

docsy.dev/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
"_check:links--warn": "npm run _check:links || (echo; echo 'WARNING: see link-checker output for issues.'; echo)",
99
"_check:links": "make --keep-going check-links",
1010
"_commit:public": "HASH=$(git rev-parse --short main); cd public && git add -A && git commit --allow-empty -m \"Site at $HASH\"",
11-
"_hugo-dev": "npm run _hugo -- --logLevel info -e dev -DFE",
12-
"_hugo": "hugo --cleanDestinationDir --themesDir ../..",
11+
"_hugo-dev-test": "npm run _hugo-dev -- --templateMetrics --templateMetricsHints",
12+
"_hugo-dev": "cross-env npm run _hugo -- -e \"${HUGO_ENVIRONMENT:-development}\" -DFE",
13+
"_hugo": "hugo --cleanDestinationDir --logLevel info --themesDir ../..",
1314
"_postbuild": "npm run _check:links--warn",
1415
"_serve": "npm run _hugo-dev -- serve --disableFastRender --renderToMemory",
1516
"build:preview": "cross-env npm run _hugo-dev -- --minify --baseURL \"${DEPLOY_PRIME_URL:-http://localhost}\"",

0 commit comments

Comments
 (0)