Generator
Create a new collection using the built-in generator.
bin/rails generate content Post
# or only include the needed action
bin/rails generate content Post show
This will create the following files:
-
app/content/posts/(all.md,.erbcontent will be added here) app/models/content/post.rbapp/controllers/content/posts_controller.rbapp/views/content/posts/index.html.erbapp/views/content/posts/show.html.erb
And adds a route: resources :posts, module: :content, only: %w[index show]
Creating new content files
v0.15.0+
Once a collection is created, you can quickly generate new content files:
bin/rails generate content Post --new
bin/rails generate content Post --new "My First Post"
This creates a new file in app/content/posts/ based on a template (if one exists).
Using templates
Drop a template file in your content directory to define the structure for new files:
-
template.md.ttgenerates respectivelyuntitled.mdandmy-first-post.md -
YYYY-MM-DD-template.md.ttgenerates respectively2025-12-18-untitled.mdand2025-12-18-my-first-post.md
Templates support ERB, so you can add dynamic content:
---
title: <%= @title %>
published_at: <%= Time.current %>
---
# <%= @title %>
Start writing hereā¦
If no template exists, an empty file with frontmatter dashes is created.
On this page