Skip Navigation
Article

Content generators

Content is usually specified individually by declaring instances of one of the site’s content types. But content can also be generated by applying a function to previously declared content.

Overview

For example you may have a set of articles each of which may specify a series of tags to classify its contents. Each article is declared individually by calling an initializer.

Now suppose we want our site to feature listings of articles associated with a specific tag. In this case a listing becomes its own content type. Since we don’t want to manually list the articles under each tag, a generator function can do the job for us.

The generator function will iterate over the articles and add them to the corresponding listings. When the site is declared all the generated listings are passed as normal content to be processed by suitable templates.

See Also

Current page is Content generators