Skip to content
Snippets Groups Projects

Add a page title to every page.

You get a title, and you get a title; everyone gets a title!

The page_title helper pushes the provided string at the end of the title, but because of the order that layouts are rendered in by ActionView, the result is always this:

<title from view> | 
<title from as specified in the controller or by its layout> | 
<title from layouts/_head>

For example: Merge Requests | GitLab.org / Gitlab Community Edition | GitLab.

All a developer needs to know is to put a page_title call describing the page in question at the start of every template.

To get everything where I wanted it to go without too much duplication, I had to make some changes around layouts, sidebars and controllers.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
218 "Merge request ##{@merge_request.iid} - " + title
219 else
220 "Merge requests - " + title
221 end
222 elsif current_controller?(:wikis)
223 "Wiki - " + title
224 elsif current_controller?(:network)
225 "Network graph - " + title
226 elsif current_controller?(:graphs)
227 "Graphs - " + title
228 else
229 title
230 end
231
232 title
233 end
  • Best use of branch name and Internet meme :)

  • Douwe Maan Added 1 commit:

    Added 1 commit:

    • 280a2124 - Fix Profiles::PasswordsController.
  • Douwe Maan Added 2 commits:

    Added 2 commits:

    • 635c8611 - Fix snippest sidebar when signed out.
    • 4d775915 - Plural instead of singular.
  • Douwe Maan Added 1 commit:

    Added 1 commit:

    • f7239683 - Include commit message in page title.
  • Douwe Maan Added 1 commit:

    Added 1 commit:

    • 9508bdc0 - Include ref in network page title.
  • Douwe Maan Added 1 commit:

    Added 1 commit:

    • 6fcdd150 - Capitalize "Git Access" in page title.
  • Douwe Maan Added 1 commit:

    Added 1 commit:

    • 0a63c1d2 - Have tree page title read "Files" for root.
  • Douwe Maan Added 2 commits:

    Added 2 commits:

    • 610ed70f - Humanize help page titles.
    • 8c4b6d42 - Set head panel title of help section.
  • Douwe Maan Added 2 commits:

    Added 2 commits:

    • e0a1d54e - Don't ignore any folder called tags :|
    • ae09c2a6 - Capitalize "X" in "New X".
  • Reassigned to @dzaporozhets

  • Author Maintainer

    @dzaporozhets A speedy review would be appreciated, because if it waits too long, this MR is bound to get into conflicts :)

  • Reassigned to @DouweM

  • Douwe Maan Added 1 commit:

    Added 1 commit:

    • 92fd3cce - Add helpers for header title and sidebar, and move setting those from controllers to layouts.
  • Douwe Maan Added 1 commit:

    Added 1 commit:

  • Reassigned to @dzaporozhets

  • username-removed-444 Status changed to merged

    Status changed to merged

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading