Hugo: Partial ACE include fails in themes

Created on 3 Jan 2015  路  8Comments  路  Source: gohugoio/hugo

Given /partials/foo.ace:

= include partials/foo.html .

Works when the partial is in the project; it isn't found when it is in a theme.

This works in both cases:

{{ partial "foo" . }}

/cc @tatsushid

Bug Stale

Most helpful comment

Thank god I found this comment before digging myself into the same rabbit hole that is templating in hugo.
Thanks @robsaunders.

All 8 comments

This is the limitation of template engines themselves (Ace, Amber etc.) function. Internally, theme template files are loaded by hugolib/site.go#prepTemplates. It loads theme template files with theme prefix so in this case, the real template name is theme/partials/foo.html in Hugo therefore you could refer it by = include theme/partials/foo.html .

partial template function knows that and tries to find it with both partials/foo.html and theme/partials/foo.html so it works but template engines don't know that so users have to specify the name with theme prefix.

To solve it, it is needed to rewrite prefTemplates to begin to find template files and build internal template trees from theme directory if it exists and next do them on layout directory and if the same template name (theme's one) already exists, overwrite it by layout's one. Now Hugo automatically use theme's if layout's doesn't exist so it would work but I can't predict how it affects other parts of Hugo.

Is this also why my Ace inner templates can't find theme/THEMENAME/layouts/_default/baseof.ace?

@trombonehero hmm... no, if that's a fact it smells like a bug. My bug.

Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't.

If this is a bug and you can still reproduce this error on the latest release or the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

I will close this as "will not fix". This have to be fixed in Ace and not here, and I'm not following up on that.

Wish I'd known this bug before I attempted to use hugo again... back to my custom rolled stuff I guess...

Like seriously, as a developer who believes XML-like templates (including HTML) are a no-go and bad practice - ace or amber seemed like a viable option to develop with in hugo, which purports to support it. But it doesn't - how can it when basic things like partial includes are completely broken? Remove support for it or clearly state it in the docs, or it IS a hugo bug, don't push the blame into the libraries you chose to use.

As a new user, spending an hour or so installing it, reading the docs to make a basic template, then realise the most basic things are broken and there's no documentation for why except a closed github thread, is really discouraging. I've actually fallen into this trap exactly twice now, once two years ago, I assumed it would be fixed by now.

This is why I wrote my own in rust. I first started writing a static generator in go but when I started I found the templating libraries to be a rats nest of broken garbage, including ace. I just wish hugo would pave over it properly, but I know it's difficult given the weirdness of go's Template stuff.

Thank god I found this comment before digging myself into the same rabbit hole that is templating in hugo.
Thanks @robsaunders.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kaushalmodi picture kaushalmodi  路  3Comments

bep picture bep  路  3Comments

chrissparksnj picture chrissparksnj  路  3Comments

MunifTanjim picture MunifTanjim  路  3Comments

ianbrandt picture ianbrandt  路  3Comments