You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

customizing-gitea.en-us.md 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. ---
  2. date: "2017-04-15T14:56:00+02:00"
  3. title: "Customizing Gitea"
  4. slug: "customizing-gitea"
  5. weight: 9
  6. toc: false
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "advanced"
  11. name: "Customizing Gitea"
  12. weight: 9
  13. identifier: "customizing-gitea"
  14. ---
  15. # Customizing Gitea
  16. Customizing Gitea is typically done using the `CustomPath` folder - by default this is
  17. the `custom` folder from the running directory, but may be different if your build has
  18. set this differently. This is the central place to override configuration settings,
  19. templates, etc. You can check the `CustomPath` using `gitea help`. You can override
  20. the `CustomPath` by setting either the `GITEA_CUSTOM` environment variable or by
  21. using the `--custom-path` option on the `gitea` binary. (The option will override the
  22. environment variable.)
  23. If Gitea is deployed from binary, all default paths will be relative to the Gitea
  24. binary. If installed from a distribution, these paths will likely be modified to
  25. the Linux Filesystem Standard. Gitea will attempt to create required folders, including
  26. `custom/`. Distributions may provide a symlink for `custom` using `/etc/gitea/`.
  27. Application settings can be found in file `CustomConf` which is by default,
  28. `CustomPath/conf/app.ini` but may be different if your build has set this differently.
  29. Again `gitea help` will allow you review this variable and you can override it using the
  30. `--config` option on the `gitea` binary.
  31. - [Quick Cheat Sheet](https://docs.gitea.io/en-us/config-cheat-sheet/)
  32. - [Complete List](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.ini.sample)
  33. If the `CustomPath` folder can't be found despite checking `gitea help`, check the `GITEA_CUSTOM`
  34. environment variable; this can be used to override the default path to something else.
  35. `GITEA_CUSTOM` might, for example, be set by an init script.
  36. - [List of Environment Variables](https://docs.gitea.io/en-us/specific-variables/)
  37. **Note:** Gitea must perform a full restart to see configuration changes.
  38. ## Customizing /robots.txt
  39. To make Gitea serve a custom `/robots.txt` (default: empty 404), create a file called
  40. `robots.txt` in the `custom` folder (or `CustomPath`) with
  41. [expected contents](http://www.robotstxt.org/).
  42. ## Serving custom public files
  43. To make Gitea serve custom public files (like pages and images), use the folder
  44. `custom/public/` as the webroot. Symbolic links will be followed.
  45. For example, a file `image.png` stored in `custom/public/`, can be accessed with
  46. the url `http://gitea.domain.tld/image.png`.
  47. ## Changing the default avatar
  48. Place the png image at the following path: `custom/public/img/avatar_default.png`
  49. ## Customizing Gitea pages
  50. The `custom/templates` folder allows changing every single page of Gitea. Templates
  51. to override can be found in the [`templates`](https://github.com/go-gitea/gitea/tree/master/templates) directory of Gitea source. Override by
  52. making a copy of the file under `custom/templates` using a full path structure
  53. matching source.
  54. Any statement contained inside `{{` and `}}` are Gitea's template syntax and
  55. shouldn't be touched without fully understanding these components.
  56. ### Customizing startpage / homepage
  57. Copy [`home.tmpl`](https://github.com/go-gitea/gitea/blob/master/templates/home.tmpl) for your version of Gitea from `templates` to `custom/templates`.
  58. Edit as you wish.
  59. Dont forget to restart your gitea to apply the changes.
  60. ### Adding links and tabs
  61. If all you want is to add extra links to the top navigation bar, or extra tabs to the repository view, you can put them in `extra_links.tmpl` and `extra_tabs.tmpl` inside your `custom/templates/custom/` directory.
  62. 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:
  63. just place it under your "custom/public/" directory (for instance `custom/public/impressum.html`) and put a link to it in `custom/templates/custom/extra_links.tmpl`.
  64. To match the current style, the link should have the class name "item", and you can use `{{AppSubUrl}}` to get the base URL:
  65. `<a class="item" href="{{AppSubUrl}}/impressum.html">Impressum</a>`
  66. You can add new tabs in the same way, putting them in `extra_tabs.tmpl`.
  67. The exact HTML needed to match the style of other tabs is in the file
  68. `templates/repo/header.tmpl`
  69. ([source in GitHub](https://github.com/go-gitea/gitea/blob/master/templates/repo/header.tmpl))
  70. ### Other additions to the page
  71. Apart from `extra_links.tmpl` and `extra_tabs.tmpl`, there are other useful templates you can put in your `custom/templates/custom/` directory:
  72. - `header.tmpl`, just before the end of the `<head>` tag where you can add custom CSS files for instance.
  73. - `body_outer_pre.tmpl`, right after the start of `<body>`.
  74. - `body_inner_pre.tmpl`, before the top navigation bar, but already inside the main container `<div class="full height">`.
  75. - `body_inner_post.tmpl`, before the end of the main container.
  76. - `body_outer_post.tmpl`, before the bottom `<footer>` element.
  77. - `footer.tmpl`, right before the end of the `<body>` tag, a good place for additional Javascript.
  78. ## Customizing Gitea mails
  79. The `custom/templates/mail` folder allows changing the body of every mail of Gitea.
  80. Templates to override can be found in the
  81. [`templates/mail`](https://github.com/go-gitea/gitea/tree/master/templates/mail)
  82. directory of Gitea source.
  83. Override by making a copy of the file under `custom/templates/mail` using a
  84. full path structure matching source.
  85. Any statement contained inside `{{` and `}}` are Gitea's template
  86. syntax and shouldn't be touched without fully understanding these components.
  87. ## Adding Analytics to Gitea
  88. Google Analytics, Matomo (previously Piwik), and other analytics services can be added to Gitea. To add the tracking code, refer to the `Other additions to the page` section of this document, and add the JavaScript to the `custom/templates/custom/header.tmpl` file.
  89. ## Customizing gitignores, labels, licenses, locales, and readmes.
  90. Place custom files in corresponding sub-folder under `custom/options`.
  91. **NOTE:** The files should not have a file extension, e.g. `Labels` rather than `Labels.txt`
  92. ### gitignores
  93. To add custom .gitignore, add a file with existing [.gitignore rules](https://git-scm.com/docs/gitignore) in it to `custom/options/gitignore`
  94. ### Labels
  95. To add a custom label set, add a file that follows the [label format](https://github.com/go-gitea/gitea/blob/master/options/label/Default) to `custom/options/label`
  96. `#hex-color label name ; label description`
  97. ### Licenses
  98. To add a custom license, add a file with the license text to `custom/options/license`
  99. ### Locales
  100. Locales are managed via our [crowdin](https://crowdin.com/project/gitea).
  101. You can override a locale by placing an altered locale file in `custom/options/locale`.
  102. Gitea's default locale files can be found in the [`options/locale`](https://github.com/go-gitea/gitea/tree/master/options/locale) source folder and these should be used as examples for your changes.
  103. To add a completely new locale, as well as placing the file in the above location, you will need to add the new lang and name to the `[i18n]` section in your `app.ini`. Keep in mind that Gitea will use those settings as **overrides**, so if you want to keep the other languages as well you will need to copy/paste the default values and add your own to them.
  104. ```
  105. [i18n]
  106. LANGS = en-US,foo-BAR
  107. NAMES = English,FooBar
  108. ```
  109. Locales may change between versions, so keeping track of your customized locales is highly encouraged.
  110. ### Readmes
  111. To add a custom Readme, add a markdown formatted file (without an `.md` extension) to `custom/options/readme`
  112. ### Reactions
  113. To change reaction emoji's you can set allowed reactions at app.ini
  114. ```
  115. [ui]
  116. REACTIONS = +1, -1, laugh, confused, heart, hooray, eyes
  117. ```
  118. A full list of supported emoji's is at [emoji list](https://gitea.com/gitea/gitea.com/issues/8)
  119. ## Customizing the look of Gitea
  120. As of version 1.6.0 Gitea has built-in themes. The two built-in themes are, the default theme `gitea`, and a dark theme `arc-green`. To change the look of your Gitea install change the value of `DEFAULT_THEME` in the [ui](https://docs.gitea.io/en-us/config-cheat-sheet/#ui-ui) section of `app.ini` to another one of the available options.
  121. As of version 1.8.0 Gitea also has per-user themes. The list of themes a user can choose from can be configured with the `THEMES` value in the [ui](https://docs.gitea.io/en-us/config-cheat-sheet/#ui-ui) section of `app.ini` (defaults to `gitea` and `arc-green`, light and dark respectively)