Skip to content

Conversation

@gwatts
Copy link
Contributor

@gwatts gwatts commented Nov 3, 2020

The "docs only" example created for issue #173 has been a super useful reference for my own internal docs site - However, I got to thinking whether Hugo's new target cascading front matter (introduced in 0.76.0) would allow us to do the same thing, with much less copying of Docsy's layout templates.

The problem with having to copy the templates, is that it becomes work to keep those templates up to date with the improvements made in the theme itself - Much better to have as little customization of those as possible.

To that end, I created a version of your example with zero custom layouts: https://github.com/gwatts/mostlydocs (example rendered: https://mostlydocs.netlify.app/ )

Getting the section menu to work correctly for that required a couple of small tweaks, which is what this PR is for.

The first commit hides the search result page from the section list on the home page. The second ensures that the home page is correctly included in the section menu, if the home page is of type "docs".

It also adds a "toc_root" parameter - I use that on the example site to add a "blog" section that does not appear in that documentation menu, so that the blog appears to be separate. Setting it to false (or omitting it), causes any blog section to be included in the tree like any other section.

Of course, if your site is really "just docs" you can just delete that blog section entirely.

None of this should have any effect on sites using Docsy today (if i've done this right ;-) ).

This introduces no change in behaviour for the default case, but for
sites that use cascade to render most pages as a "docs" type, it allows
the tree to be correctly rooted from the home page (type docs itself)
and also allows specific sections to act as their own separate root, by
setting toc_root=true in their front matter.
@LisaFC
Copy link
Collaborator

LisaFC commented Nov 9, 2020

Oh this is brilliant! You definitely weren't able to do this back when I created the "just docs" site (or at least not nearly so gracefully). Do you want to add docs on how to create a site that uses this feature as well - maybe on the increasingly huge "Adding content" page (which we may need to split)?

@honzik20
Copy link

This sounds perfect.

@gwatts
Copy link
Contributor Author

gwatts commented Nov 11, 2020

Great! I wrote up some docs. I agree that page could probably use a bit of restructuring at some point; hopefully someone will have the time and inclination to take that on :-)

@LisaFC
Copy link
Collaborator

LisaFC commented Nov 12, 2020

I love it! Thanks so much for this. Merging now.

@LisaFC LisaFC merged commit dba99bb into google:master Nov 12, 2020
@LisaFC
Copy link
Collaborator

LisaFC commented Nov 12, 2020

@gwatts do you want to send a mail to the docsy-users list letting people know about the new feature? I'll update the example site with the latest Docsy as well.

@gwatts
Copy link
Contributor Author

gwatts commented Nov 12, 2020

thanks @LisaFC ! Post sent!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants