Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More control over titles #15

Open
ghost opened this issue Feb 6, 2010 · 6 comments
Open

More control over titles #15

ghost opened this issue Feb 6, 2010 · 6 comments

Comments

@ghost
Copy link

ghost commented Feb 6, 2010

Can we have an option to attach the site title to all the page titles. So default title would be "MySite" and then when you go to an article page it would be something like "MySite - Some Article Title". Is this possible now?

@ghost
Copy link
Author

ghost commented Feb 6, 2010

Ok, found a simple way to do it right now. Here's the code for the above example:

 <title><% if @path == 'index' %>MySiteTitle<% else %> MySiteTitle - <%= title %><% end %></title>

@ghost
Copy link
Author

ghost commented Feb 6, 2010

Ok, above solution isn't going to serve proper titles for pages. Here's a better one:

<% if @path == 'index' %>
  MySite
<% elsif @path.split('/').compact.length == 4 %>
  MySite - <%= title %>
<% else %>
  MySite - <%= @path.capitalize.gsub(/[-]/, ' ') %>
<% end %>

The second condition checks if the page is an article. A bit of a hack but works.

@vertiginous
Copy link

FWIW, here's the solution I came up with.

http://gist.github.com/300095

@vertiginous
Copy link

ok, it's late. That didn't work at all. This is better.

http://gist.github.com/300095

@davejacobs
Copy link

I want to put my vote in for making this easier, as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants