# How to display static html content using layouts in rails

**URL:** <https://www.ruby-forum.com/t/how-to-display-static-html-content-using-layouts-in-rails/106660>\
**Category:** Rails\
**Created:** [June 12, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/how-to-display-static-html-content-using-layouts-in-rails/106660 "2007-06-12T23:43:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Sehlhorst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@Scott\_Sehlhorst](https://www.ruby-forum.com/u/Scott_Sehlhorst)\
**Post date:** [June 12, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/how-to-display-static-html-content-using-layouts-in-rails/106660/1 "2007-06-12T23:43:40Z")

</div>

Need: Include an “about page” in a ruby on rails site.  
Goal: Minimize hassle, maximize DRY (e.g. nav menus, sidebars, etc)

Approach: Create a trivial controller, designed solely to present  
static (or dynamic) content.

Assumptions: You have a working ruby on rails application at  
[www.example.com](http://www.example.com)  
(or [example.com/app/](http://example.com/app/) or whatever).

Steps:

1. create the new controller: ruby script/generate controller static
2. assign a layout if not already assigned in application.rb: layout  
“standard-layout”
3. create an empty action : def about end
4. create action.rhtml - put all the content in here. - it gets  
wrapped with the layout
5. add a mapping in routes.rb: map.connect ‘about’, :controller =\>  
“static”, :action =\> “about”

Notes: you can also do any dynamic rails stuff in the “static” page,  
or use content\_for to modify the standard layout, or whatever.

The mapping (5) tells rails to send [www.example.com/about/](http://www.example.com/about/) to your  
“static” controller (you can name it anything), and the “about” action  
(the names don’t have to match). The rhtml file (4) holds the html  
you want presented - and any dynamic code you want to include will  
work here too. The action (3) tells rails to render the rhtml file  
(4) when called via the mapping (5). The content (4) is wrapped in  
the layout (2).

The answers that I found to this problem (for my site) were not really  
clearly spelled out for ruubs like myself. Just thought I’d give back  
a little. Hope this gets indexed well and helps someone.

Scott Sehlhorst  
[http://tynerblain.com/nexus/about](http://tynerblain.com/nexus/about)
