Posts tagged searchkick

Preprocessing in Searchkick

2016-02-04T00:00:00.000Z

Coming back to Jekyll from Hugo, I’d grown accustomed to shortcodes, which are awesome to keep your Markdown source as HTML-free as possible. You can emulate shortcodes with custom liquid tags! In your folder, create a new file, and then write a class that inherits from . Let’s see an example below of a tag for embedding Youtube videos: The general thing to take note of here is that whatever appears after the tag name will be stringified and sent to the second argument of , so for example, a custom tag that looks like: in the method above will be (note the trailing whitespace). There’s no further treatment, so you will have to parse the string yourself somehow to identify what is what, and then assign what you need to instance variables: The class must also implement a method, which returns a string representation of the HTML, so in this case of Youtube embeds: And voila! You can now use your Youtube tag like so: Great success 👍