# Render :partial in /app/views/layouts

**URL:** <https://www.ruby-forum.com/t/render-partial-in-app-views-layouts/166098>\
**Category:** Rails\
**Created:** [April 21, 2009, 9:19pm UTC](https://www.ruby-forum.com/t/render-partial-in-app-views-layouts/166098 "2009-04-21T21:19:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trevor\_Menagh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f6c823/32.png) [@Trevor\_Menagh](https://www.ruby-forum.com/u/Trevor_Menagh)\
**Post date:** [April 21, 2009, 9:19pm UTC](https://www.ruby-forum.com/t/render-partial-in-app-views-layouts/166098/1 "2009-04-21T21:19:20Z")

</div>

Hi all,

I have many layouts that apply to parts of my Rails site. Some of the  
elements of each of the layouts are the same. I would like to create  
something like a partial to use within layouts.

For example, I might have two layouts that have identical   
information, but different formatting.

Is there a way to separate out the identical information so I can DRY  
up my layout code? I didn’t have much luck creating partials in the  
layout directory.

Thanks,  
trv

---

<div class="post-metadata">

**Author:** ![Trevor\_Menagh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f6c823/32.png) [@Trevor\_Menagh](https://www.ruby-forum.com/u/Trevor_Menagh)\
**Post date:** [April 21, 2009, 10:09pm UTC](https://www.ruby-forum.com/t/render-partial-in-app-views-layouts/166098/2 "2009-04-21T22:09:58Z")

</div>

After doing some searching I found nested-layouts ([http://github.com/](http://github.com/)  
radar/nested-layouts/tree/master). It seems to do the trick, although  
to get it to work with my Rails 2.3.2 app, I had to change part of  
line 13 of lib/nested\_layouts.rb from ‘app/views/layouts’ to “#  
{RAILS\_ROOT}/app/views/layouts”

If anyone has some better/alternative solutions, I am all ears.

trv

---

<div class="post-metadata">

**Author:** ![Trevor\_Menagh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f6c823/32.png) [@Trevor\_Menagh](https://www.ruby-forum.com/u/Trevor_Menagh)\
**Post date:** [April 21, 2009, 10:13pm UTC](https://www.ruby-forum.com/t/render-partial-in-app-views-layouts/166098/3 "2009-04-21T22:13:30Z")

</div>

Actually partials in the layout directory work fine (like in any other  
dir), but you need to specify the directory explicitly:

layouts/  
\_head.html.erb  
application.html.erb

In application.html.erb  
\<%= render :partial =\> ‘layouts/head’ %\>

Dmitry
