custom/ directory and survive code updates.
Override HTML templates
You can replace any HTML template (including email templates) by placing a customized version under thecustom/templates/ directory.
Find the original template
Locate the template file you want to customize in the
templates/ directory of the Gogs source code. For example, to customize the home page, find templates/home.tmpl.Copy and edit
Copy the content of the template file and save your edited version to the corresponding path under
custom/templates/. For example:Override static files
You can replace static files (CSS, JavaScript, images, etc.) by placing customized versions under thecustom/public/ directory.
For example, to override the site favicon, place your version at:
Inject custom content
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 |
Example: custom CSS file
The following example shows how to include a custom CSS file in your Gogs instance:Link the stylesheet
Edit the file
custom/templates/inject/head.tmpl and add a link to your CSS file: