Page Models are a powerful way to manage sets of pages and access their content programmatically from all other parts of the website. For example, if a website wants to feature pages for each member of their team, they might create the following pages in ./pages/people.

The first page we'd create lives at ./pages/people/

name: Brad Gessler
title: Open Source Developer

I created Sitepress!

Then we add another person at ./pages/people/

name: Linus Torvalds
title: Creator of Linux

I created Linux!

Then we'd create a PersonPage model at ./models/person_page.rb:

require "digest/md5"

class PersonPage < Sitepress::Model
  collection glob: "people/*.html*"
  data :name, :title, :email

  def gravatar_image_url

Finally, from any template on the website, the collection of people can be iterated by calling:


<% PersonPage.all.each do |person| %>
  <div class="person">
    <h2><%= %></h2>
    <img src="<%= person.gravatar_image_url%>"/>
    <a href="mailto:<%=>"><%= %></a>
    <a href="<%= person.request_url %>">Read bio</a>
<% end %>

Page Models are a powerful and convenient way to access collections of content on websites.