We would like to use server side includes (SSI) in the content of our nanoc site. This would allow us to chunk shared information and include it in multiple pages. It would also allow us to only maintain one source file of this shared information.
I figured out how to add an SSI (partial) in nanoc. As you know in nanoc we have the following root level folders, among others:
/content/
/layouts/
According to the instructions I found (http://nanoc.ws/docs/basics/#as-partials), it seems the “partials” or include files need to be in the /layouts/ folder (outside of the /content/ folder).
For example: The following code is used to insert the include file /layouts/partials/shared/test.html
<%= render 'partials/shared/test/' %>
In other words, the code assumes the include file will be placed in the layouts folder. Do you know of a way to change the default path for SSIs to /content/? This way we won’t mix content with layouts?
Thank you in advance.
Partials by default are in the layouts/ directory, and are used through the rendering helper using the
#render
helper method.However, you can also put content to include (“partials”) in the content/ directory, too, although the approach then is different.
For example, create
content/partials/foo.txt
:Make sure the partial files are not routed nor compiled, so edit
Rules
and ensure these rules are executed first:Now in any item or layout you can include this partial:
This assumes the includer item/layout is filtered using ERB, but you could also use Haml or so.
You can let the compile rule do some processing, e.g. perform Markdown filtering, and then the HTML output from the filter will be included.