How do I change GitLab <title>?

2019-04-10 23:27发布

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.

标签: gitlab
2条回答
爷、活的狠高调
2楼-- · 2019-04-10 23:43
该账号已被封号
3楼-- · 2019-04-10 23:47

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.

查看更多
登录 后发表回答