Add configurable site_title appearance setting to change instance webpage title

What does this MR do and why?

This MR adds a new section in the Admin Area "Appearance" settings tab, allowing instance admins to add a custom title for their GitLab instance that will be added at the end of the page title, in the user's browser tab.

I picked this feature as this is something I wish to configure on my personal GitLab CE instance. I believe this would also be a good addition for my customers using GitLab, which could customize their instances further.

Another good use case for this feature would be having an easy way to differentiate between production and test environments.

As a side note, apologies if the implementation is a bit dirty, I am slowly getting back into GitLab code after some time. In any case, feedback is very much welcome. I am not sure if I would need one of those "Changelog" entries as well.

Database

Migrations

Migrate:

gdk@gdk:/gitlab-gdk/gitlab-development-kit/gitlab$ RAILS_ENV=development scripts/db_tasks db:migrate:up VERSION=20260320152051
Running: `bundle exec rake db:migrate:up:main VERSION=20260320152051`
main: == [advisory_lock_connection] object_id: 137960, pg_backend_pid: 641881
main: == 20260320152051 AddSiteNameToAdminAppearanceSettings: migrating =============
main: -- add_column(:appearances, :site_name, :text, {:null=>true})
main:    -> 0.0016s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("ALTER TABLE appearances\nADD CONSTRAINT check_6da7d01e1a\nCHECK ( char_length(site_name) <= 255 )\nNOT VALID;\n")
main:    -> 0.0010s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0005s
main: -- execute("ALTER TABLE appearances VALIDATE CONSTRAINT check_6da7d01e1a;")
main:    -> 0.0007s
main: -- execute("RESET statement_timeout")
main:    -> 0.0005s
main: == 20260320152051 AddSiteNameToAdminAppearanceSettings: migrated (0.0357s) ====

main: == [advisory_lock_connection] object_id: 137960, pg_backend_pid: 641881

Migrate down:

gdk@gdk:/gitlab-gdk/gitlab-development-kit/gitlab$ RAILS_ENV=development scripts/db_tasks db:migrate:down VERSION=20260320152051
Running: `bundle exec rake db:migrate:down:main VERSION=20260320152051`
main: == [advisory_lock_connection] object_id: 137940, pg_backend_pid: 639945
main: == 20260320152051 AddSiteNameToAdminAppearanceSettings: reverting =============
main: -- remove_column(:appearances, :site_name, {:if_exists=>true})
main:    -> 0.0123s
main: == 20260320152051 AddSiteNameToAdminAppearanceSettings: reverted (0.0211s) ====

main: == [advisory_lock_connection] object_id: 137940, pg_backend_pid: 639945
New queries introduced

!228333 (diffs) :

SELECT
    "appearances".*
FROM
    "appearances"
ORDER BY
    "appearances"."id" ASC
LIMIT 1;

Query plan

gitlabhq_development=# EXPLAIN ANALYSE SELECT
    "appearances".*
FROM
    "appearances"
ORDER BY
    "appearances"."id" ASC
LIMIT 1;
                                                               QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=0.14..0.28 rows=1 width=769) (actual time=0.053..0.053 rows=1 loops=1)
   ->  Index Scan using appearances_pkey on appearances  (cost=0.14..13.64 rows=100 width=769) (actual time=0.049..0.049 rows=1 loops=1)
 Planning Time: 0.632 ms
 Execution Time: 0.090 ms
(4 rows)

Query plan link: https://explain.depesz.com/s/TB7e

References

  • "Add user-defined text to website title for better integration with password managers": #15075 (closed)
  • Heavily based on previous attempt: !69644 (closed)

Screenshots or screen recordings

Before After
image image
image image

Notice how the title "PurpleLabs" is added to the page title.

Video showcase:

Steps shown:

  • Default configuration
  • Setting a title
  • Removing a title

How to set up and validate locally

Assuming GDK-in-a-box setup with the GitLab Community fork. This also assumes either a clean DB from master.

  1. Checkout branch jae/feat/15075-custom-instance-title
  2. Run migrations through bundle exec rake db:migrate
  3. Visit http://gdk.local:3000 and observe the page title is Home - GitLab
  4. Visit http://gdk.local:3000/admin/application_settings/appearance
  5. Set Site name to a value such as MyCompany
  6. Validate with the Update appearance settings button below
  7. Visit http://gdk.local:3000 and observe the page title is Home - MyCompany

MR acceptance checklist

I believe that the conditions are met on my end. Sadly it seems I cannot assign additional labels to request reviews.

Edited by Jae Lo Presti

Merge request reports

Loading