| name | Custom template |
|---|
You can override HTML templates (including templates for emails) by creating a customized version under custom/templates/ directory. Your version of HTML templates will survive code updates, but you may want to keep tabs on them in case functionality changes. Be careful when overriding HTML templates as you may break things in future releases.
An example is to customize the look and contents of the home page:
- Copy the content of template file
templates/home.tmpl. - Save edited file as
custom/templates/home.tmpl.
[server] LOAD_ASSETS_FROM_DISK = true
You can override static files (CSS, JavaScript, images, etc.) by creating a customized version under custom/public/ directory. Your version of static files will survive code updates, but you may want to keep tabs on them in case functionality changes. Be careful when overriding static files as you may break things in future releases.
For example, you can override the site favicon by putting your version of favicon to custom/public/img/favicon.png.
You can inject your custom head or footer content to Gogs without touching source code of main repository. This is useful if you want to add analytics code or include custom static resources.
You can read more about injecting a custom head and footer here..
This approach is recommended whenever possible because it has the minimum impact on templates.
Here is an example of how you can include a custom CSS file in your Gogs instance. Names and directories are just for demonstration, you can put it anywhere as long as it can be accessed via network requests.
- Create a file named
custom.cssundercustom/public/css/directory. - Put some CSS rules into the file.
- Edit file
custom/templates/inject/head.tmpland add a line<link rel="stylesheet" href="/css/custom.css"> - Restart Gogs.
- Future edits to the custom CSS file DO NOT require restarting Gogs.