# Titles for tagged pages

**URL:** <https://www.ruby-forum.com/t/titles-for-tagged-pages/56621>\
**Category:** Typo\
**Created:** [April 1, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621 "2006-04-01T21:07:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![shokk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@shokk](https://www.ruby-forum.com/u/shokk)\
**Post date:** [April 1, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621/1 "2006-04-01T21:07:14Z")

</div>

This is probably a quickie. I’d like to see pages that are tag links,  
such  
as [http://www.website.com/blog/articles/tag/blah](http://www.website.com/blog/articles/tag/blah) have a title of "  
[Website.com](http://Website.com) - Blah", where currently the title is only set to  
“[Website.com](http://Website.com)”.  
How can I set that? More importantly so that it’s not overwritten each  
time  
I svn update. 😉 The reason for this is that most page tracking  
systems,  
like Mint, will key on the page titles when aggregating the data, so  
tagged  
pages do not count any diffferently than the front page.

---

<div class="post-metadata">

**Author:** ![shokk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@shokk](https://www.ruby-forum.com/u/shokk)\
**Post date:** [April 2, 2006, 1:55am UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621/2 "2006-04-02T01:55:46Z")

</div>

On Sunday 02 April 2006 05:05, Ernie O. wrote:

> This is probably a quickie. I’d like to see pages that are tag links, such  
> as [http://www.website.com/blog/articles/tag/blah](http://www.website.com/blog/articles/tag/blah) have a title of "  
> [Website.com](http://Website.com) - Blah", where currently the title is only set to  
> “[Website.com](http://Website.com)”. How can I set that?

Inside the tag method of articles\_controller.rb, you probably want to  
assign  
@page\_title to the title you want.

> More importantly so that it’s not overwritten each time I svn update. 😉

This is probably pointing out the obvious, but when you make changes to  
any  
files in a SVN repository, those changes are preserved when you svn  
update.

TX

---

<div class="post-metadata">

**Author:** ![shokk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@shokk](https://www.ruby-forum.com/u/shokk)\
**Post date:** [April 2, 2006, 5:14am UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621/3 "2006-04-02T05:14:24Z")

</div>

I found this in app/helpers/articles\_helper.rb

def page\_title  
if @page\_title  
@page\_title  
else  
this\_blog.blog\_name || “Typo”  
end  
end

I’m trying to add something like  
+ " - #{tag.display\_name}"  
somewhere but I can’t seem to find where and how.

---

<div class="post-metadata">

**Author:** ![shokk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@shokk](https://www.ruby-forum.com/u/shokk)\
**Post date:** [April 2, 2006, 5:29am UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621/4 "2006-04-02T05:29:27Z")

</div>

You might try doing exactly what Trejkaz suggested. In app/  
controllers/articles\_controller.rb, look for the method you want to  
override the title for and set @page\_title there.

---

<div class="post-metadata">

**Author:** ![shokk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@shokk](https://www.ruby-forum.com/u/shokk)\
**Post date:** [April 2, 2006, 7:24am UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621/5 "2006-04-02T07:24:36Z")

</div>

I found this in app/controllers/articles\_controller.rb as the only  
mention  
of @page\_title or tags.

def tag  
render\_grouping(Tag)  
end  
def view\_page  
if(@page = Page.find\_by\_name(params[:name].to\_a.join(‘/’)))  
@page\_title = @page.title  
else  
render :nothing =\> true, :status =\> 404  
end  
end

and setting the @page\_title line to  
@page\_title = @page.title + " - #{tag.display\_name}"  
doesn’t produce anything when the URL is  
[http://www.website.com/blog/articles/tag/blah](http://www.website.com/blog/articles/tag/blah)

The text I’m trying to add to the title is dynamic based on the tag if  
the  
path includes “articles/tag”, so it’s not a predefined text I’m setting.  
In  
fact it should probably work that way for categories, too.

I’ll keep digging to see how this all works with articles\_controller.rb  
Complete newb here, if you haven’t noticed. =)

---

<div class="post-metadata">

**Author:** ![shokk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@shokk](https://www.ruby-forum.com/u/shokk)\
**Post date:** [April 2, 2006, 11:02am UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621/6 "2006-04-02T11:02:55Z")

</div>

On Sunday 02 April 2006 15:23, Ernie O. wrote:

> ```
> render :nothing => true, :status => 404
> end
> 
> ```
> 
> end
> 
> and setting the @page\_title line to  
> @page\_title = @page.title + " - #{tag.display\_name}"  
> doesn’t produce anything when the URL is  
> [http://www.website.com/blog/articles/tag/blah](http://www.website.com/blog/articles/tag/blah)

I think you might be getting a bit confused here. You want to set the  
title  
in the “tag” method, not the “view\_page” method. It’s the tag pages  
which  
you want to have the title, right?

TX

---

<div class="post-metadata">

**Author:** ![shokk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@shokk](https://www.ruby-forum.com/u/shokk)\
**Post date:** [April 3, 2006, 8:53pm UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621/7 "2006-04-03T20:53:57Z")

</div>

Yes, you have it right, Trejkaz. I think I see the light now.  
Thanks for your pointer about the site name, Scott.

---

<div class="post-metadata">

**Author:** ![shokk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@shokk](https://www.ruby-forum.com/u/shokk)\
**Post date:** [April 3, 2006, 3:52pm UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621/8 "2006-04-03T15:52:40Z")

</div>

One thing to remember–the search engine optimization people  
generally_discourage_ putting your site name in the   
ofpages–apparently it causes a noticable drop in search  
engineperformance.

Scott

---

<div class="post-metadata">

**Author:** ![shokk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@shokk](https://www.ruby-forum.com/u/shokk)\
**Post date:** [July 4, 2006, 5:52am UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621/9 "2006-07-04T05:52:44Z")

</div>

Finally got around to posting this one-liner as a patch in Trac:  
[http://www.typosphere.org/trac/ticket/958](http://www.typosphere.org/trac/ticket/958)

This lets systems like Mint identify when people visit category or tag  
groupings which would otherwise show as the blog name, the same as the  
front  
page would. This might be good for other places like pagination and  
archive  
pages.

---

<div class="post-metadata">

**Author:** ![shokk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@shokk](https://www.ruby-forum.com/u/shokk)\
**Post date:** [April 3, 2006, 11:37pm UTC](https://www.ruby-forum.com/t/titles-for-tagged-pages/56621/10 "2006-04-03T23:37:08Z")

</div>

On Monday 03 April 2006 23:50, Scott L. wrote:

> One thing to remember–the search engine optimization people  
> generally_discourage_ putting your site name in the   
> ofpages–apparently it causes a noticable drop in search engineperformance.

Now that’s interesting. Those same people used to tell you to put it in  
there  
because it raised performance. Let me guess – every spam site on the  
internet then did it, and thus the odds of a real site doing it fell  
dramatically, and we ended up back at step 1.

In any case, should Typo remove the site name from all the titles? 🙂

TX
