In contrary to most CMSs pages in Alchemy do not hold the actual content. The actual content is stored in ingredients inside of elements pages are built of.

Pages have a unique friendly url and are organized as nested tree and represent the structure of your website.

Beside a language, a page has attributes for name, title, visibility, published and restriction status and all SEO relevant attributes like meta tags and meta descriptions.

Every page has a definition which defines additional properties like caching, uniqueness and it defines elements that can be placed on that Page.

Defining page types

Page types are defined in the config/alchemy/page_layouts.yml file.

Every page type needs at least a name. You don't need to set every option. It depends on what you need for pages with that type.

  • name String required

    The name of the page type used for views and inside the database. You can render a page by type with the render_page_layout(name) helper.

  • elements Array

    A list of element names that can be placed on this type of page i.e. [text, picture].

    Elements are defined inside the elements.yml file.

  • autogenerate Array

    A list of element names that are autogenerated after creating a Page of that type.

  • unique Boolean (Default false)

    Pass true and the user can only choose this page type once inside a language tree.

  • cache Boolean (Default true)

    Pass false to disable the cache headers for this kind of pages. Recommended for contact forms and such likes.

  • layoutpage Boolean (Default false)

    Layout pages (or global pages) are outside the normal page tree and can be used to place "global" Elements like a header and footer.

  • taggable Boolean (Default false)

    Pass true to be able to assign tags within page settings.

Optional settings

  • hide Boolean (Default false)

    Pass true to hide this page type from the user.

  • searchresults Boolean (Default false)

    Pass true to use this type of page for rendering the search results of the build in fulltext search.

  • feed Boolean (Default false)

    Pass true to enable a RSS feed of news elements from this page.

  • controller String

    Controller to use instead of the default Alchemy::PagesController

  • action String

    Controllers action to use instead of the default Alchemy::PagesController#show


Lets say you want to create a contact page with a headline element, a contactform and a text element on it.

This page should be unique, because you don't want to give your content manager the possibility to create more than one contact form.

This page must not be cached, because of validation messages and user specific form content.

We also want to autogenerate the headline and the contactform element after the page gets created.

# config/alchemy/page_layouts.yml
- name: contact
  cache: false
  unique: true
  elements: [headline, contactform, text]
  autogenerate: [headline, contactform]


Please ensure to restart the Rails server after editing page_layouts.yml.

Page templates

Each page type (called page_layout in Alchemy) has a Rails view partial which is yielded on the Rails application layout (app/views/layouts/application.html.erb).

All page type partials live in the app/views/alchemy/page_layouts folder.

They are named after the pages page_layout you defined in the page_layouts.yml file.


If no page type partial is found for a page, the _standard.html.erb partial gets rendered instead.

Template generator

There is no need to create these partials manually. AlchemyCMS comes with a Rails generator task which creates these partials for you.

So after defining the page layouts, you can generate all the corresponding partials for them.

bin/rails g alchemy:page_layouts --skip

Using the example above, which defines a contact page type, the generator will create a partial named _contact.html.erb.


You can pass --template-engine or -e as option to use one of haml, slim and erb. The default depends on your default template engine in your Rails host app.

Rendering elements

Alchemy does not place any HTML markup in your generated page layouts partial.


<%= render_elements %>

is all you will see. Feel free to customize the HTML so it fits your needs.


The render_elements view helper has lots of options. Please have a look at the Alchemy::ElementsHelper documentationopen in new window

Global pages

Global pages (or layout pages) are pages that are not in the default page tree (your navigation). They will never get rendered on its own. Use them to store shared elements that should be rendered on multiple other pages (ie. footer, header, tracking codes etc) or somewhere directly on the application layout.

To define a global page set layoutpage: true in the page type definition of that page.

Render an element from a global page

To render an element from a global page use the from_page option of the render_elements helper.


<%= render_elements only: 'news_teaser', from_page: Alchemy::Page.find_by(name: 'sidebar') %>


You can pass a page_layout name as a String, an Array of page type names, or an instance of a certain Alchemy::Page.


If using the global caching option (defined in config/alchemy/config.yml) - which is enabled by default - your page requests will deliver cache headers. Most browsers, CDNs and proxys use these headers to cache the page.


You can disable cache headers for certain pages by using the cache: false setting.

Russian doll caching

You can use Rails' "Russian-Doll-Caching" to cache page templates.

<% cache @page do %>
  <%= render_elements %>
<% end %>


Be sure to not cache page templates that have elements with forms on it, like contact or comment forms. Rails' csrf protection token is placed inside the <form> tag and caching it will break form submissions.

Translate page type names

Page type names are passed through the I18n library. You can translate them in your Alchemy locale files.


# config/locales/
      contact: Kontakt
      search: Suche


All translation keys used by Alchemy are scoped under the alchemy namespace.