I’m the maintainer of the Bilberry Hugo Theme and at the moment im struggeling with the following topic (maybe this is useful for other users / developers and someone has an idea how to handle the issue):
Link to the issue: https://github.com/Lednerb/bilberry-hugo-theme/issues/208
This theme uses Content Types in form of
They all have the same overall structure in a partial that is called
For each content type there are specific header, for example the options to include a youtube-video or a spotify-song to the
For using the different content types I’ve also created the specific partials and there the problem arises:
Example with the “My trip to Scotland” example post:
Inherits from the
_default/baseof.html and includes the correct partial:
partials/content-type/gallery.html partial will include the
partials/default-content.html and contains the features for the gallery-slider and also the correct fontawesome icon is set:
default-content.html is included (for many other content types also):
In an earlier version I’ve included the
default-content as a normal partial via the
However, it seems that partials get cached and when using the same structure above for the
list view, the contents of
default-content will not be rendered correctly and in an unpredictable way.
What I’ve tried so far
In the last days I changed the code to use the
partialCached instruction while setting also a
$PAGE_TYPE variable in the hope to tell hugo to render the
default-content partial twice - once for the list view with the summary output and the continue reading link; once for the single page content.
However the rate of race-conditions regarding the cache are dropped from almost 10% to only 1% the theme is nevertheless in an unstable status at the moment.
The next approach today has the idea of using
blocks and inherit from the
_default/single.html file, refactoring the partials with the respective templates (for example:
audio/single.html etc.) but it seems that inheritance is not possible in an flexible way to prevent breaking the DRY-principle.
Thank you for reading this topic!
I appreciate any tips regarding the issue and how it might can be fixed without producing a lot of duplicated code.