Skip to content

klevo/title_tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title_tag for Rails

Set HTML title tag from within Rails views.

API

In your layout file (application.html.erb for example) create the title tag in the <head> section like this:

<%= title_tag 'My App' %> ...

This will output <title>My App</title>.

In your views you can then use:

<%= title "Curriculum" %>

This will set the page title to "Curriculum - My App" and print <h1>Curriculum<h1> at the same time.

If you just want to set the title without printing anything, use:

<% title "Curriculum" %>

You can pass an option to the title method to not append the global title to the title you're creating:

<% title "Very special page.", no_append: true %>

This results in page title being set to just "Very special page.".

That's it, enjoy.

About

Set HTML title tag from within Rails views.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published