Forester 5.0 › Publishing and implanting forests [30FN]

Forester now includes an experimental feature to “publish” a portion of your forest to a JSON blob that can be read by Forester and implanted into another forest. For example, if you include the following code in a tree within your forest, then a file will be emitted at output/my-forest.json containing the compiled content of your entire forest, together with all the assets:

\syndicate-query-as-json-blob{my-forest}{
 \datalog{
  ?X -: {\rel/in-host ?X '{www.my-great-forest.net}}
 }
}

Of course, more sophisticated queries can be used. For example, you can emit all the items tagged public together as follows:

\syndicate-query-as-json-blob{my-public-forest}{
 \datalog{
   ?X -: {\rel/has-tag ?Z '{public}}
 }
}

To implant the resulting JSON file into another forest, simply copy over the file and add the following line to your configuration file:

[forest]
foreign = [{ path = "my-public-forest.json" }]

By default, implanted trees will be rendered to your output folder underneath a foreign/ directory; if you wish to instead that links to implanted trees be routed directly to their canonical URLs (which will likely be the case if you implant a public forest), then you may configure that as follows:

[forest]
foreign = [{ path = "my-public-forest.json", route_locally = false }]

This feature is highly experimental and has many limitations; it will change in breaking ways in the near future. Although we are very interested to learn about the limitations of this feature, we will be taking a hands-off approach to support until the feature has taken a more stable form.