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.

93 lines
4.2 KiB

  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 `custom` folder. This is the central
  17. place to override configuration settings, templates, etc.
  18. If Gitea is deployed from binary, all default paths will be relative to the gitea
  19. binary. If installed from a distribution, these paths will likely be modified to
  20. the Linux Filesystem Standard. Gitea will create required folders, including `custom/`.
  21. Application settings are configured in `custom/conf/app.ini`. Distributions may
  22. provide a symlink for `custom` using `/etc/gitea/`.
  23. - [Quick Cheat Sheet](https://docs.gitea.io/en-us/config-cheat-sheet/)
  24. - [Complete List](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.ini.sample)
  25. If the `custom` folder can't be found next to the binary, check the `GITEA_CUSTOM`
  26. environment variable; this can be used to override the default path to something else.
  27. `GITEA_CUSTOM` might, for example, be set by an init script.
  28. - [List of Environment Variables](https://docs.gitea.io/en-us/specific-variables/)
  29. **Note:** Gitea must perform a full restart to see configuration changes.
  30. ## Customizing /robots.txt
  31. To make Gitea serve a custom `/robots.txt` (default: empty 404), create a file called
  32. `robots.txt` in the `custom` folder with [expected contents](http://www.robotstxt.org/).
  33. ## Serving custom public files
  34. To make Gitea serve custom public files (like pages and images), use the folder
  35. `custom/public/` as the webroot. Symbolic links will be followed.
  36. For example, a file `image.png` stored in `custom/public/`, can be accessed with
  37. the url `http://gitea.domain.tld/image.png`.
  38. ## Changing the default avatar
  39. Place the png image at the following path: `custom/public/img/avatar\_default.png`
  40. ## Customizing Gitea pages
  41. The `custom/templates` folder allows changing every single page of Gitea. Templates
  42. to override can be found in the `templates` directory of Gitea source. Override by
  43. making a copy of the file under `custom/templates` using a full path structure
  44. matching source.
  45. Any statement contained inside `{{` and `}}` are Gitea's templete syntax and
  46. shouldn't be touched without fully understanding these components.
  47. ### Adding links and tabs
  48. 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.
  49. 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:
  50. 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`.
  51. To match the current style, the link should have the class name "item", and you can use `{{AppSubUrl}}` to get the base URL:
  52. `<a class="item" href="{{AppSubUrl}}/impressum.html">Impressum</a>`
  53. You can add new tabs in the same way, putting them in `extra_tabs.tmpl`.
  54. The exact HTML needed to match the style of other tabs is in the file
  55. `templates/repo/header.tmpl`
  56. ([source in GitHub](https://github.com/go-gitea/gitea/blob/master/templates/repo/header.tmpl))
  57. ### Other additions to the page
  58. Apart from `extra_links.tmpl` and `extra_tabs.tmpl`, there are other useful templates you can put in your `custom/templates/custom/` directory:
  59. - `header.tmpl`, just before the end of the `<head>` tag where you can add custom CSS files for instance.
  60. - `body_outer_pre.tmpl`, right after the start of `<body>`.
  61. - `body_inner_pre.tmpl`, before the top navigation bar, but already inside the main container `<div class="full height">`.
  62. - `body_inner_post.tmpl`, before the end of the main container.
  63. - `body_outer_post.tmpl`, before the bottom `<footer>` element.
  64. - `footer.tmpl`, right before the end of the `<body>` tag, a good place for additional Javascript.
  65. ## Customizing gitignores, labels, licenses, locales, and readmes.
  66. Place custom files in corresponding sub-folder under `custom/options`.