Skip to content

Allow hooking rendering of .Content with a content-hook.html #762

@mhansen

Description

@mhansen

Hi there, this is an experience report, and an idea for how we might make Docsy updates more transparent.

For sites like this ProfilerPedia I have "175 Profilers, 140 Data Formats, 125 Converters, 116 Analysis UIs", I want to model them in Hugo with a different layout per-type: that is, I have layouts/formats/, layouts/profilers/, layouts/converters/, and layouts/uis/.

And the same on Graphviz, where I have different layouts for /outputs/ e.g. https://graphviz.org/docs/outputs/bmp/ and attributes e.g. https://graphviz.org/docs/attrs/background/.

I still want the header / docs sidebar / tag cloud. I just want to override the content. The only way to do this seems to be by copying the entire layout/docs/single.html page and adding my extra tags, which makes my site brittle to Docsy updates.

I ended up overriding content.html (and deleting a bunch of features I don't use) and overriding single.html.

I think if you changed {{ .Content }} in layout/docs/single.html (and a few other templates) to {{ .Render "content-hook.html" }} or something, where the default content-hook.html just contains "{{ .Content }}", then I could hook that call and only add my extra per-type content inside the Docsy docs theme. I think there are some other overridable hook templates for other things, and maybe it wouldn't be too hard to add one for {{ .Content }} ?

Like I could say (to achieve the same as what I'm doing here):

layouts/profilers/content-hook.html:

<b>Docs</b> {{ .Params.docs }}
{{ .Content }}

To add some extra fields above my content that are always there for all pages of type 'profiler'.

More details at mhansen/profilerpedia#12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions