This past week, I started building out a solo Rails project, and one of my first steps was to create a general layout for my nav bar, footer, and columns, so that I could use a cohesive structure across my site.
Since I wanted the layout to be pretty standard for all pages (and since the nav and footer are static html), I decided to use Rail’s built-in render file method, so that I wouldn’t have to house my bulky html on the application.html.erb file (or within individual pages, if I ever decide not to use them across the whole site.)
Using render is simple. Create a file containing the html to be rendered (check out render partial if you need to render more than just static content) and place it in a folder in the views directory. Then, in application.html.erb (or wherever you’d like to render your code), simply render the file in erb tags, like this:
Check out the Rails docs for more extensive info about rendering partials and templates.