docs/advancing/custom-templates.mdx
Gogs allows you to customize the appearance and behavior of your instance by overriding HTML templates, replacing static files, and injecting custom content. All customizations are placed under the custom/ directory and survive code updates.
You can replace any HTML template (including email templates) by placing a customized version under the custom/templates/ directory.
```
custom/templates/home.tmpl
```
You can replace static files (CSS, JavaScript, images, etc.) by placing customized versions under the custom/public/ directory.
For example, to override the site favicon, place your version at:
custom/public/img/favicon.png
You can inject custom HTML into the head or footer of every page without touching the main repository source code. This is useful for adding analytics code, custom stylesheets, or other static resources.
This approach is recommended whenever possible because it has the minimum impact on templates and is less likely to break during upgrades.
The injection points are:
| File | Location | Purpose |
|---|---|---|
custom/templates/inject/head.tmpl | Inside <head> | Add stylesheets, meta tags, analytics scripts |
custom/templates/inject/footer.tmpl | Before </body> | Add scripts, tracking code, custom footer content |
The following example shows how to include a custom CSS file in your Gogs instance:
<Steps> <Step title="Create the CSS file"> Create a file named `custom.css` under the `custom/public/css/` directory:```
custom/public/css/custom.css
```
```css
/* custom/public/css/custom.css */
.dashboard .news .news-item .header {
color: #333;
}
footer {
background-color: #f5f5f5;
}
```
```html
<link rel="stylesheet" href="/css/custom.css">
```