Gerrit supports some customization of the HTML it sends to the browser, allowing organizations to alter the look and feel of the application to fit with their general scheme.
HTML Header/Footer and CSS for login screens
At startup Gerrit reads the following files (if they exist) and uses them to customize the HTML page it sends to clients:
HTML is inserted below the menu bar, but above any page content. This is a good location for an organizational logo, or links to other systems like bug tracking.
HTML is inserted at the bottom of the page, below all other content, but just above the footer rule and the "Powered by Gerrit Code Review (v….)" message shown at the extreme bottom.
The CSS rules are inlined into the top of the HTML page, inside of a
<style>tag. These rules can be used to support styling the elements within either the header or the footer.
The *.html files must be valid XHTML, with one root element,
typically a single
<div> tag. The server parses it as XML, and
then inserts the root element into the host page. If a file has
more than one root level element, Gerrit will not start.
Static image files can also be served from
and may be referenced in
GerritSite.css by the relative URL
To simplify security management, files are only served from
'$site_path'/static. Subdirectories are explicitly forbidden from
being served from this location by enforcing the rule that file names
\. (Client requests for
will result in 404 Not Found responses.)
The header, footer, and CSS files are inlined into the host page, which is always sent with a no-cache header. Clients will see any changes immediately after they are made.
'$site_path'/static whose file name matches one of the
following patterns are served with a 1 year expiration, permitting
very aggressive caching by clients and edge-proxies:
All other assets under
'$site_path'/static are served with a 5
minute expire, permitting some (limited) caching. It may take up
to 5 minutes after making a change, before clients see the changes.
It is recommended that static images used in the site header
or footer be named with a unique caching file name, for example
my_logo1.cache.png, to allow browsers to take advantage of their
disk cache. If the image needs to be modified, create a new file,
my_logo2.cache.png and update the header (or footer) HTML to
reference the new image path.
Google Analytics Integration
To connect Gerrit to Google Analytics add the following to your
Please consult the Google Analytics documentation for the correct setup code (the first two script tags). The above is shown only as a reference example.
If your footer is otherwise empty, wrap all of the script tags into
<div> tag (like above) to ensure it is a well-formed
XHTML document file.
The global function
Gerrit.on("history") accepts functions that
accept a string parameter. These functions are put into a list and
invoked any time Gerrit shifts URLs. You’ll see page names like
/c/123 be passed to these functions, which in turn are handed off
to Google Analytics for tracking. Our example hook above uses '/'
instead of '#' because Analytics won’t track anchors.
window.onload callback is necessary to ensure that the
Gerrit.on() function has actually been defined by the
Part of Gerrit Code Review