Skip to content

Commit ffc0bff

Browse files
AlbertoGPlafriks
authored andcommitted
Improve documentation about custom templates. (#3345)
Now includes all the template hooks in the page, and a detailed example for the common case of adding an "about" page.
1 parent be1330e commit ffc0bff

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

docs/content/doc/advanced/customizing-gitea.en-us.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,32 @@ matching source.
6262
Any statement contained inside `{{` and `}}` are Gitea's templete syntax and
6363
shouldn't be touched without fully understanding these components.
6464

65-
To add custom HTML to the header or the footer of the page, in the `templates/custom`
66-
directory there is `header.tmpl` and `footer.tmpl` that can be modified. This can be
67-
a useful place to add custom CSS files or additional Javascript.
65+
### Adding links and tabs
6866

6967
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.
7068

69+
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:
70+
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`.
71+
72+
To match the current style, the link should have the class name "item", and you can use `{{AppSubUrl}}` to get the base URL:
73+
`<a class="item" href="{{AppSubUrl}}/impressum.html">Impressum</a>`
74+
75+
You can add new tabs in the same way, putting them in `extra_tabs.tmpl`.
76+
The exact HTML needed to match the style of other tabs is in the file
77+
`templates/repo/header.tmpl`
78+
([source in GitHub](https://github.com/go-gitea/gitea/blob/master/templates/repo/header.tmpl))
79+
80+
### Other additions to the page
81+
82+
Apart from `extra_links.tmpl` and `extra_tabs.tmpl`, there are other useful templates you can put in your `custom/templates/custom/` directory:
83+
84+
- `header.tmpl`, just before the end of the `<head>` tag where you can add custom CSS files for instance.
85+
- `body_outer_pre.tmpl`, right after the start of `<body>`.
86+
- `body_inner_pre.tmpl`, before the top navigation bar, but already inside the main container `<div class="full height">`.
87+
- `body_inner_post.tmpl`, before the end of the main container.
88+
- `body_outer_post.tmpl`, before the bottom `<footer>` element.
89+
- `footer.tmpl`, right before the end of the `<body>` tag, a good place for additional Javascript.
90+
7191
## Customizing gitignores, labels, licenses, locales, and readmes.
7292

7393
Place custom files in corresponding sub-folder under `custom/options`.

0 commit comments

Comments
 (0)