Building Pages
Lean CMS stores content in a database. Your ERB templates pull that content out using helpers. This section explains the full flow — from defining what content a page has, to seeding initial values, to rendering it in your own design.
The three-layer model
YAML structure file Database Your ERB template
───────────────────── ────────────────────── ─────────────────────────
pages: → lean_cms_page_contents → <%= page_content(@page,
home: page | section | key 'hero', 'heading') %>
sections:
hero:
heading:
type: text
default: "Welcome"
- Structure — You define pages, sections, and fields in
config/lean_cms_structure.yml - Seeding —
rails lean_cms:generate_structurecreates database rows from the YAML - Rendering — Your ERB calls helpers to retrieve and display the stored values
Content hierarchy
Every piece of CMS content has three coordinates:
| Level | Example | Description |
|---|---|---|
| Page | home |
Maps to a route/controller action |
| Section | hero |
A named area within that page |
| Key | heading |
An individual field within that section |
Content is retrieved with page_content(@page, 'section', 'key').
Sections with edit overlays
Wrap any block of HTML in cms_editable_section to give logged-in CMS users a hover-activated edit button:
<%= cms_editable_section(page: 'home', section: 'hero', display_title: 'Hero') do %>
<section class="hero">
<h1><%= page_content(@page, 'hero', 'heading') %></h1>
<p><%= page_content(@page, 'hero', 'subheading') %></p>
</section>
<% end %>
When a CMS editor hovers over this section, an “Edit” button appears. Visitors see nothing — no wrappers, no extra markup.
Next steps
- Your First Page — a complete walkthrough
- Content Types — all 9 field types and how to render them
- Seeding Content — define your structure in YAML