Page Objects

At their foundation evey webpage that you create in Render Engine is a Page object.

Basic Page from Template

The simplest page (possibly your index) will only require some basic information.


class BasicPage(Page):
    template = 'template_file.html' # user provided template

The @site.register_route decorator adds an initialized version of the class to the specified site’s routes array.

The template attribute is passed to the page’s engine (either manually defined or assigned by the engine). This template will be used when creating your Markup.

If no template is defined, the content will be converted to Markup and generated.

Adding Metadata to your Page

Page objects have attributes that your html page will use. Different types of pages may require certain attributes but pages should check for those required attributes and supply placeholders/ and necessary warning messages.

Here are some attributes that can modify how your Page generates content.

Adding Variables to your Page

The default engine to generate your Page is Jinja2 <>. Jinja allows for you to supply variables to your templates. These variables are the attributes you supply your Page object with.:

# Basic Page with Variables
class PageWithVars(Page):
    title = 'Site Title'
    template = template_file.html

# templates/template_file.html

# output/pagewithvars.html
    <title>Site Title</title>

# Page Loading from File
class PageFromFile(Page):
    content_path = '' # loaded from content path can be '.md' or '.html'

# Page Inherited from Other Page
class BasicPage(Page):
    template = 'template_file.html' # user provided template
    title = 'Base Page'

class InheritingPage(BasicPage):
    # template will be inherited from the BasicPage
    title = 'Inherited Page'