Julien__
Julien__

Reputation: 2038

How to run Jekyll plugin after include tags?

I use {% include text.md %} in my posts to include some often typed paragraphs.

I have a Generator plugin that makes some text replacement in post contents.

However, the text inside the included files (e.g. text.md) is not processed by this plugin.

How can I run the plugin after includes are performed but before html is rendered? Or how could I do things differently to make it work?

Upvotes: 0

Views: 180

Answers (1)

ashmaroli
ashmaroli

Reputation: 5434

Jekyll processes a site in distinct "phases".

  reset >> read >> generate >> render >> cleanup >> write

A Generator subclass is generally used to "generate" objects (Pages or Documents) that are then rendered based on the prioritydefined for the generator.

An include tag (or any Liquid constructs) is "rendered" in the subsequent phase.

Unfortunately, you cannot alter the "raw content" of a file in the middle of the rendering phase. Jekyll provides you with just a :pre_render hook to manipulate unrendered content of a file.

Upvotes: 2

Related Questions