--- date: "2017-04-15T14:56:00+02:00" title: "Customizing Gitea" slug: "customizing-gitea" weight: 9 toc: false draft: false menu: sidebar: parent: "advanced" name: "Customizing Gitea" identifier: "customizing-gitea" weight: 9 --- # Customizing Gitea Customizing Gitea is typically done using the `CustomPath` folder - by default this is the `custom` folder from the running directory, but may be different if your build has set this differently. This is the central place to override configuration settings, templates, etc. You can check the `CustomPath` using `gitea help`. You can also find the path on the _Configuration_ tab in the _Site Administration_ page. You can override the `CustomPath` by setting either the `GITEA_CUSTOM` environment variable or by using the `--custom-path` option on the `gitea` binary. (The option will override the environment variable.) If Gitea is deployed from binary, all default paths will be relative to the Gitea binary. If installed from a distribution, these paths will likely be modified to the Linux Filesystem Standard. Gitea will attempt to create required folders, including `custom/`. Distributions may provide a symlink for `custom` using `/etc/gitea/`. Application settings can be found in file `CustomConf` which is by default, `$GITEA_CUSTOM/conf/app.ini` but may be different if your build has set this differently. Again `gitea help` will allow you review this variable and you can override it using the `--config` option on the `gitea` binary. - [Quick Cheat Sheet](https://docs.gitea.io/en-us/config-cheat-sheet/) - [Complete List](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.example.ini) If the `CustomPath` folder can't be found despite checking `gitea help`, check the `GITEA_CUSTOM` environment variable; this can be used to override the default path to something else. `GITEA_CUSTOM` might, for example, be set by an init script. You can check whether the value is set under the "Configuration" tab on the site administration page. - [List of Environment Variables](https://docs.gitea.io/en-us/specific-variables/) **Note:** Gitea must perform a full restart to see configuration changes. **Table of Contents** {{< toc >}} ## Serving custom public files To make Gitea serve custom public files (like pages and images), use the folder `$GITEA_CUSTOM/public/` as the webroot. Symbolic links will be followed. For example, a file `image.png` stored in `$GITEA_CUSTOM/public/`, can be accessed with the url `http://gitea.domain.tld/image.png`. ## Changing the default logo To build a custom logo replace `assets/logo.svg` and run `make generate-images`. This will update these customizable logo files which you can then place in `$GITEA_CUSTOM/public/img` on your server: - `public/img/logo.svg` - `public/img/logo.png` - `public/img/favicon.png` - `public/img/avatar_default.png` - `public/img/apple-touch-icon.png` ## Changing the default avatar Either generate it via above method or place the png image at the following path: - `$GITEA_CUSTOM/public/img/avatar_default.png` ## Customizing Gitea pages and resources Gitea's executable contains all the resources required to run: templates, images, style-sheets and translations. Any of them can be overridden by placing a replacement in a matching path inside the `custom` directory. For example, to replace the default `.gitignore` provided for C++ repositories, we want to replace `options/gitignore/C++`. To do this, a replacement must be placed in `$GITEA_CUSTOM/options/gitignore/C++` (see about the location of the `CustomPath` directory at the top of this document). Every single page of Gitea can be changed. Dynamic content is generated using [go templates](https://golang.org/pkg/html/template/), which can be modified by placing replacements below the `$GITEA_CUSTOM/templates` directory. To obtain any embedded file (including templates), the [`gitea embedded` tool]({{< relref "doc/advanced/cmd-embedded.en-us.md" >}}) can be used. Alternatively, they can be found in the [`templates`](https://github.com/go-gitea/gitea/tree/master/templates) directory of Gitea source (Note: the example link is from the `master` branch. Make sure to use templates compatible with the release you are using). Be aware that any statement contained inside `{{` and `}}` are Gitea's template syntax and shouldn't be touched without fully understanding these components. ### Customizing startpage / homepage Copy [`home.tmpl`](https://github.com/go-gitea/gitea/blob/master/templates/home.tmpl) for your version of Gitea from `templates` to `$GITEA_CUSTOM/templates`. Edit as you wish. Dont forget to restart your gitea to apply the changes. ### Adding links and tabs If all you want is to add extra links to the top navigation bar or footer, or extra tabs to the repository view, you can put them in `extra_links.tmpl` (links added to the navbar), `extra_links_footer.tmpl` (links added to the left side of footer), and `extra_tabs.tmpl` inside your `$GITEA_CUSTOM/templates/custom/` directory. For instance, let's say you are in Germany and must add the famously legally-required "Impressum"/about page, listing who is responsible for the site's content: just place it under your "$GITEA_CUSTOM/public/" directory (for instance `$GITEA_CUSTOM/public/impressum.html`) and put a link to it in either `$GITEA_CUSTOM/templates/custom/extra_links.tmpl` or `$GITEA_CUSTOM/templates/custom/extra_links_footer.tmpl`. To match the current style, the link should have the class name "item", and you can use `{{AppSubUrl}}` to get the base URL: `Impressum` For more information, see [Adding Legal Pages](https://docs.gitea.io/en-us/adding-legal-pages). You can add new tabs in the same way, putting them in `extra_tabs.tmpl`. The exact HTML needed to match the style of other tabs is in the file `templates/repo/header.tmpl` ([source in GitHub](https://github.com/go-gitea/gitea/blob/master/templates/repo/header.tmpl)) ### Other additions to the page Apart from `extra_links.tmpl` and `extra_tabs.tmpl`, there are other useful templates you can put in your `$GITEA_CUSTOM/templates/custom/` directory: - `header.tmpl`, just before the end of the `
` tag where you can add custom CSS files for instance. - `body_outer_pre.tmpl`, right after the start of ``. - `body_inner_pre.tmpl`, before the top navigation bar, but already inside the main container `