@@ -71,7 +71,7 @@ site content root. Hugo automatically applies the appropriate **template** for
7171that section, depending on which folder the content is in. For example, this
7272page 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
7575particular page.
7676
7777If 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
135135about 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
290192possible 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/
0 commit comments