SEO & Sitemaps
RailsFast has been designed for SEO and discoverability from the ground up. Your project, immediately upon deployment, should score 100/100 on SEO and close to 100/100 on overall performance on Google PageSpeed Insights:
Other than technical improvements and good technical architecture, your main two ways of affecting on-page SEO on your RailsFast app are: metadata and the sitemap.
Metadata
We use the meta-tags gem to handle on-page metadata. Everything is already configured and you'll see examples throughout the codebase.
Setting title and description in views
The easiest way to set page metadata is directly in your view files using the title and description helpers:
<% title "My page" %>
<% description "This is the SEO description for my page" %>
You can also combine them in a single ERB block:
<%
title "My page"
description "This is the SEO description for my page"
%>
Dynamic titles and descriptions
For pages with dynamic content, you can use Ruby expressions:
<%
title @product ? "#{@product.name} - Shop" : "All Products"
description @product ?
"Buy #{@product.name} for only $#{@product.price}. #{@product.short_description}" :
"Browse our full catalog of products with fast shipping."
%>
Setting metadata in controllers
Alternatively, set metadata in your controller actions using instance variables:
def show
@product = Product.find(params[:id])
@page_title = @product.name
@page_description = @product.description.truncate(160)
end
Open Graph images
Set a custom OG image for social sharing:
set_meta_tags og: { image: "https://example.com/og-image.jpg" }
Private pages (noindex)
For pages that shouldn't appear in search results (like user dashboards, account settings, or authenticated areas), use noindex and nofollow:
<%
title "Your Account Settings"
description "Manage your account preferences and settings."
set_meta_tags noindex: true, nofollow: true
%>
This tells search engines not to index the page or follow its links, keeping private content out of search results.
Sitemaps
Your app sitemap is available at /sitemaps/sitemap.xml.gz
If you're using the CMS/blog system, the sitemap automatically includes all your content with smart behavior (auto-discovery, visibility flags, priority assignment, empty section handling). The footer also adapts automatically to your content structure. See the Sitemap and Footer sections in the CMS docs for details.
Custom URLs
You can configure what URLs go in the sitemap by editing your config/sitemap.rb file. You can dynamically add thousands of URLs by iterating over all your database records. We leverage the sitemap_generator gem for this, read their docs to know what's possible!
You can also enable automatic sitemap discovery in your robots.txt file by uncommenting the sitemap line at the end of the file.
Automatic refresh
The sitemap is automatically regenerated daily via SitemapRefreshJob (configured in config/recurring.yml). To regenerate manually, run rails sitemap:refresh:no_ping or trigger the job from console with SitemapRefreshJob.perform_later.
TODO: make sure Cloudflare is not blocking sitemaps / are readable by GSC
Slugs
If you want to create SEO-friendly URLs, I recommend using the slugifiable gem.
This will allow you to have semantic URLs like
https://myapp.com/products/big-red-backpack
instead of
https://myapp.com/products/14
The slugifiable gem does not come pre-configured by default in RailsFast because it's very app-dependent, but it should take you just ~5 minutes to set up!