TheBlackzone Logo

Include static HTML content in your Habari posts

Posted on Friday, June 5, 2015 by TheBlackzone

Habari Icon When I switched to the Habari publishing platform, I had a bunch of automatically created HTML content that I wanted to be included in my posts and pages. Mainly this content was created by some Perl scripts and automatically uploaded to my web server. Updates occurred quite often and so I had the urge to avoid time-consuming manual updates.

To remedy this, I wrote a very simple Habari plugin named "IncStatic" that checks posts before the are displayed and if a post contains tags of the form <!--file="..."--> it replaces these tags with the content of the given file.

Example and usage

Here's an example of a posts content using IncStatic:

<h1>This is the page title</h1> <p>This page includes some static HTML from another file. Here is the content of that file:</p> <hr> <!--file="static1.html"--> <hr> <p>This text is part of the page again. Maybe some explanatory text for the content that had been included. Of course you can include multiple files, so here's another one:</p> <hr> <!--file="static2.html"--> <hr> <p>And here's the end of the page</p> 

This includes the content of the files static1.html and static2.html at the respective positions.

Filenames are specified relative to the root folder (which is e.g. public_html or htdocs) of the website. For example

<!--file="static1.html"--> 

includes the file "static1.html" from the web root, while

<!--file="files/static2.html"--> 

includes the file "static2.html" from the folder "files". In the latter case there mustn't be a leading slash!

Get and install it

If you think this plugin could be useful to you, you're welcome to freely download and use it. As always, it's provided as is and you use it entirely at your own risk.

That said, installation is totally simple:

Tags: website, habari, howto

Button Previous2015 Website Reboot

Howto install Quake 3 Arena on XubuntuButton Next