How do I change GitLab <title>?

2019-04-10 23:10发布

问题:

I've looked and looked and can't find it..I want to change the page title

<title>GitLab</title>

to include more information. I can't seem to find anywhere to do this as i've scoured github and don't see any answers.

回答1:

When you consider a page like app/views/layouts/devise.html.haml, you see:

!!! 5
%html{ lang: "en"}
  = render "layouts/head"      <=====
  %body.ui_basic.login-page
    = render "layouts/flash"
    .container
      .content
        %center
          %h1 GitLab

That means the <head> part of the html result is generated by app/views/layouts/_head.html.haml:

%head
  %meta{charset: "utf-8"}
  %title
    = "#{title} | " if defined?(title)
    GitLab

That is where that GitLab comes from.

As explained in this haml reference document, the title is modified with @title:

# file: app/controllers/movies_controller.rb

class MoviesController < ApplicationController
  def index
    @title = "Teen Wolf"
  end
end

For instance, the GitLab source 'app/controllers/users_controller.rb' modifies the title.

But I don't see any way to put as a parameter the default title which is put when a controller doesn't define a title.
So you may have to modify directly that _head.html.haml file.



回答2:

I created a fork for gitlab just for titles.

https://github.com/anezi/gitlabhq

You can check the diff: https://github.com/anezi/gitlabhq/compare/gitlabhq:6-3-stable...6-3-stable



标签: gitlab