[Rails-core] The tag</span></a></span> </h1> <p class="darkgray font13"> <span class="sender pipe"><a href="/search?l=rubyonrails-core@googlegroups.com&q=from:%22David+Knorr%22" rel="nofollow"><span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">David Knorr</span></span></a></span> <span class="date"><a href="/search?l=rubyonrails-core@googlegroups.com&q=date:20090517" rel="nofollow">Sun, 17 May 2009 13:19:33 -0700</a></span> </p> </div> <div itemprop="articleBody" class="msgBody"> <!--X-Body-of-Message--> <pre> Currently, there is no dedicated solution for making page titles in Ruby on Rails. However, there is lots of custom solutions out there. A few examples:</pre><pre> The instance variable: View: <h1><%= @title = "Hello world" %></h1> Layout: <title>Awesome Site | <%= @title || "Your main source of awesomeness" %></title> The content_for helper: <h1><% content_for :title, "Hello world" %></h1> <title>Awesome Site | <%= yield :title || "Your main source of awesomeness" %> Besides this, there's also a few people that prefer to set the page title in the controller. I wouldn't recommend that, though. I recently posted a ticket on Lighthouse including a patch for Rails that would allow you to use this syntax: View: <h1><%= title "Hello world" %></h1> Layout: <%= title(:site => "Awesome Site") %> Which will output: <title>Awesome Site - Hello World</title> Two configuration options are available: * reverse, reverses the order of page title and site name. Default is false, site name first. * separator, defines the separator of the page title and the site name. Default is " - ". More information on the patch here: <a rel="nofollow" href="https://rails.lighthouseapp.com/projects/8994/tickets/2657-helper-for-generating-the-title-tag">https://rails.lighthouseapp.com/projects/8994/tickets/2657-helper-for-generating-the-title-tag</a> Now, my question to you is: Which of the above solutions do you prefer? If you have a completely different solution I would also like to hear about it. -- Best regards, David Knorr <a rel="nofollow" href="http://twitter.com/perplect">http://twitter.com/perplect</a> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscr...@googlegroups.com For more options, visit this group at <a rel="nofollow" href="http://groups.google.com/group/rubyonrails-core?hl=en">http://groups.google.com/group/rubyonrails-core?hl=en</a> -~----------~----~----~----~------~----~------~--~--- </pre> </div> <div class="msgButtons margintopdouble"> <ul class="overflow"> <li class="msgButtonItems"><a class="button buttonleft " accesskey="p" href="msg09043.html">Previous message</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="c" href="index.html#09044">View by thread</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="i" href="maillist.html#09044">View by date</a></li> <li class="msgButtonItems textalignright"><a class="button buttonright " accesskey="n" href="msg09045.html">Next message</a></li> </ul> </div> <a name="tslice"></a> <div class="tSliceList margintopdouble"> <ul class="icons monospace"> <li class="icons-email tSliceCur"><span class="subject">[Rails-core] The <title> tag</span> <span class="sender italic">David Knorr</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg09045.html">[Rails-core] Re: The <title> tag</a></span> <span class="sender italic">Mislav Marohnić</span></li> </ul> </ul> </div> <div class="overflow msgActions margintopdouble"> <div class="msgReply" > <h2> Reply via email to </h2> <form method="POST" action="/mailto.php"> <input type="hidden" name="subject" value="[Rails-core] The <title> tag"> <input type="hidden" name="msgid" value="11b354ad-6e55-4acb-95ba-8724480aca93@b1g2000vbc.googlegroups.com"> <input type="hidden" name="relpath" value="rubyonrails-core@googlegroups.com/msg09044.html"> <input type="submit" value=" David Knorr "> </form> </div> </div> </div> <div class="aside" role="complementary"> <div class="logo"> <a href="/"><img src="/logo.png" width=247 height=88 alt="The Mail Archive"></a> </div> <form class="overflow" action="/search" method="get"> <input type="hidden" name="l" value="rubyonrails-core@googlegroups.com"> <label class="hidden" for="q">Search the site</label> <input class="submittext" type="text" id="q" name="q" placeholder="Search rubyonrails-core"> <input class="submitbutton" name="submit" type="image" src="/submit.png" alt="Submit"> </form> <div class="nav margintop" id="nav" role="navigation"> <ul class="icons font16"> <li class="icons-home"><a href="/">The Mail Archive home</a></li> <li class="icons-list"><a href="/rubyonrails-core@googlegroups.com/">rubyonrails-core - all messages</a></li> <li class="icons-about"><a href="/rubyonrails-core@googlegroups.com/info.html">rubyonrails-core - about the list</a></li> <li class="icons-expand"><a href="/search?l=rubyonrails-core@googlegroups.com&q=subject:%22%5C%5BRails%5C-core%5C%5D+The+%3Ctitle%3E+tag%22&o=newest&f=1" title="e" id="e">Expand</a></li> <li class="icons-prev"><a href="msg09043.html" title="p">Previous message</a></li> <li class="icons-next"><a href="msg09045.html" title="n">Next message</a></li> </ul> </div> <div class="listlogo margintopdouble"> </div> <div class="margintopdouble"> </div> </div> </div> <div class="footer" role="contentinfo"> <ul> <li><a href="/">The Mail Archive home</a></li> <li><a href="/faq.html#newlist">Add your mailing list</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/faq.html#support">Support</a></li> <li><a href="/faq.html#privacy">Privacy</a></li> <li class="darkgray">11b354ad-6e55-4acb-95ba-8724480aca93@b1g2000vbc.googlegroups.com</li> </ul> </div> </body> </html> <script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'9fde23b3fd694bc2',t:'MTc3OTE0MTY3Ng=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script>