What's the plan for plugins?

I think it would be really great to add a plugin architecture on top of the existing theme layout. I’m thinking that a “plugin” would mostly consist of prebuilt shortcodes and partials. For example there could be an SEO plugin that would add a bunch of meta tags to the head, including og tags. A well written plugin would have levels of partials. At the most basic level, you could put this in your header: {{ partial "plugin/seo/all.html" }} That call would hopefully be composed of sub-partials, so if you wanted more control, you could call the specific pieces:

{{ partial "plugin/seo/opengraph.html" }}
{{ partial "plugin/seo/twittercards.html" }}
{{ partial "plugin/seo/googleplus.html" }}

I’m just in the middle of writing this type of stuff now, and it’s pretty reusable. It’d be nice to be able to open source it, make updates easily available and have an convenient way to inject it into my projects. Obviously it won’t be as plug and play as a WordPress plugin, but if that’s what you’re looking for, you’re probably not using Hugo.

It doesn’t seem like it would be that much more overhead to iterate through a few plugin directories to register shortcodes and partials, especially since most of that merge code already exists to support themes.

The other major benefit about having some cornerstone plugins is that it could allow for theme standardization without clogging up the core. I’m thinking that there could be a semi-canonical plugin for things like authors. I coded a way to register all the users in config.toml that’s accessible inside partials and templates, and I’ve seen it implemented in different ways in all the different themes for the showcase. With some standardization, maybe through a plugin, you could depend on that as a theme and you could easily switch from theme to theme without having to adjust all of your front matter.

4 Likes

Will you (@devs) add support for plugins on top of Hugo?! (It’s necessary to have support for calendars and localizations via plugins)

1 Like

Great, The same feature request for same issue