# Best way to allow client to do SEO on view files?

**URL:** <https://www.ruby-forum.com/t/best-way-to-allow-client-to-do-seo-on-view-files/114550>\
**Category:** Rails\
**Created:** [September 14, 2007, 9:35pm UTC](https://www.ruby-forum.com/t/best-way-to-allow-client-to-do-seo-on-view-files/114550 "2007-09-14T21:35:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [September 14, 2007, 9:35pm UTC](https://www.ruby-forum.com/t/best-way-to-allow-client-to-do-seo-on-view-files/114550/1 "2007-09-14T21:35:51Z")

</div>

I’m about to start work on a project for a client that is huge into SEO  
and conversion tracking, etc. One of the goals of the project is to make  
sure that each (HTML) page’s meta information can be tweaked separately.  
But, I still want to make liberal use of layouts to keep with the DRY  
philosophy (and because all his older projects used untemplated files  
and were NIGHTMARES to try to work with)

Does anyone know of a good way of handling this? Are partials the best  
way? Oh, and the client id comfortable with HTML, but Ruby might be a  
stretch for him (though he can work his way around PHP pretty well).

I have a few more questions on related topics, but I’ll use different  
threads so as not to confuse the conversation.

Thanks!

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [September 17, 2007, 10:10am UTC](https://www.ruby-forum.com/t/best-way-to-allow-client-to-do-seo-on-view-files/114550/2 "2007-09-17T10:10:33Z")

</div>

Chris B. wrote:

> I’m about to start work on a project for a client that is huge into SEO  
> and conversion tracking, etc. One of the goals of the project is to make  
> sure that each (HTML) page’s meta information can be tweaked separately.

if each page is required to be tweaked separately, why not save the  
tweaked info into the db? (gathering you have a Pages table or something  
similar) and then you could just gather the info per page, in the  
layout:

layout.rhtml

 \> ... .. .

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [September 17, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/best-way-to-allow-client-to-do-seo-on-view-files/114550/3 "2007-09-17T13:23:04Z")

</div>

> I’m about to start work on a project for a client that is huge into SEO  
> and conversion tracking, etc. One of the goals of the project is to make  
> sure that each (HTML) page’s meta information can be tweaked separately.  
> But, I still want to make liberal use of layouts to keep with the DRY  
> philosophy (and because all his older projects used untemplated files  
> and were NIGHTMARES to try to work with)
> 
> Does anyone know of a good way of handling this? Are partials the best  
> way? Oh, and the client id comfortable with HTML, but Ruby might be a  
> stretch for him (though he can work his way around PHP pretty well).

In your view at the very top:

\<% @page\_title = ‘My Page Title’ -%\>  
\<% @meta\_description = ‘My Meta Description’ -%\>  
\<% @meta\_keywords = ‘my key words’ -%\>

In your layout:

\<%= @page\_title ? @page\_title : "Some Default" %\> \<%= @meta\_keywords ? "" : "" %\> \<%= @meta\_description ? "" : "" %\>

Works great for us. It also allows us to set the @page\_title and  
@meta\_description to something relevant for instances of say  
/product/show/1 and /product/show/2 by using attributes of @product in  
the  
view…

-philip

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [September 17, 2007, 3:15pm UTC](https://www.ruby-forum.com/t/best-way-to-allow-client-to-do-seo-on-view-files/114550/4 "2007-09-17T15:15:25Z")

</div>

Shai R. wrote:

> if each page is required to be tweaked separately, why not save the  
> tweaked info into the db? (gathering you have a Pages table or something  
> similar) and then you could just gather the info per page, in the  
> layout:

That’s an option I hadn’t considered. I’m not sure that that fits our  
need 100% as the client will need to tweak these often, and building a  
whole new administrative piece for modifying meta data would be  
cumbersome. Thanks for the suggestion though!

Philip H. wrote:

> In your view at the very top:
> 
> \<% @page\_title = ‘My Page Title’ -%\>  
> \<% @meta\_description = ‘My Meta Description’ -%\>  
> \<% @meta\_keywords = ‘my key words’ -%\>
> 
> In your layout:
> 
> \<%= @page\_title ? @page\_title : "Some Default" %\> \<%= @meta\_keywords ? "" : "" %\> \<%= @meta\_description ? "" : "" %\>

Wonderful! I think that makes sense and fits our needs. Thank you.
