When generating topic-based outputs, Glyph uses layouts to render topics as standalone documents. By default, the following two layout are used:
topic
— used to render standard topics.index
— used to render the index page of your document.
Layouts are nothing more than “fancy” Glyph macros defined using the Glyph language (i.e. by using macro rewriting) within a single
.glyph
file.
Topic Layout
The default layout used to render all web topics (the layout used for web5 topics is very similar) is defined as follows:
Note that it takes the following attributes, passed automatically by Glyph when processing each topic:
title
— the title of the topic.id
— the ID of the topic.contents
— the body of the topic.
Index Layout
The default layout used to render the web index page (the layout used for the web5 index is very similar) is defined as follows:
Index layouts do not take any attribute or parameter (basically because they are used to produce only one page).
Creating a Custom Layout
To create a custom layout, proceed as follows:
- Create a
.glyph
file in thelib/layouts
directory, within your project, e.g.mytopic.glyph
- Add the layout code, making sure (for topic layouts) that all the attributes (
title
,id
,contents
) are specified correctly. - Set the
output.*.layouts.topic
setting to the name of the new layout (mytopic
).