Theme pulling Template partial from root?

Loving Hugo so far but there are a couple of small issues I can’t seem to figure out on my own.

I’d like to maintain a theme that multiple sites/clients will use for their documentation. I’ve done this with a git submodule in the themes directory. So far so good!

Problem is that there are aspects of the theme template we’d like to expose to the user. For example, in the sidebar we’d like to let them inject their own HTML block for a mailchimp form.

As I understand it the template and partial keywords don’t look backwards in the root. Is there any pattern I could use to accomplish this?

Secondly it would be great if there was some way to do:

if CustomSidebarBlock.html exists then 
   use it
else
    do nothing so hugo command line doesn't freak out!

Maybe I missed something but it’s a real head-scratcher.

It should, but I believe there is a open bug about it …

I believe views is what you look for:

1 Like

Views!!! That did it. Thanks

Just to be thorough in case anyone else has this issue here’s what I did:

I created an empty file called:

<rootdir>/themes/MYTHEME/layouts/_default/customsidebar.html

and rendered it in my sidebar.html partial using:

{{ .Render "customsidebar" }}

Now if it’s present in the root folder as <rootdir>/layouts/_default/customsidebar.html it gets used

Very handy.

1 Like