使用 caddy 为 gitea 创建 GitHub 页面 (以及更多页面)
This allows you to have github pages (with more features) in Gitea. This also requires you to setup a wildcard CNAME to your gitea host.
For now markdown files (with .md extension) will also be automatically generated to HTML.
The Caddyfile below creates a webserver listening on :3000 which will interact with gitea on using agiteatoken as the token.
The agiteatoken should be a token from gitea that has the necessary read rights on the repo's that you want to expose.
{
order gitea before file_server
}
:3000
gitea {
server https://yourgitea.yourdomain.com
token agiteatoken
domain pages.yourdomain.com #this is optional
}This works with a wildcard domain. So you'll need to make a *.pages.yourdomain.com CNAME to the server you'll be running caddy on. (this doesn't need to be the same server as gitea).
Depending on the gitea config below you'll be able to access your pages using:
There are multiple options to expose your repo's as a page, that you can use both at the same time.
e.g. we'll use the yourorg org.
gitea-pages repo in yourorg orggitea-pages topic to this gitea-pages repo (this is used to opt-in your repo),gitea-pages branch in this gitea-pages repo.Your content will now be available on
e.g. we'll use the yourrepo repo in the yourorg org and there is a file.html in the master branch and a otherfile.html in the dev branch. The master branch is your default branch.
gitea-pages topic to the yourrepo repo (this is used to opt-in your repo).gitea-pages branch in this yourrepo repo.gitea-pages.toml file in this gitea-pages branch of yourrepo repo. (more info about the content below)The gitea-pages.toml file will contain the git reference (branch/tag/commit) you allow to be exposed.
To allow everything use the example below:
allowedrefs=["*"]To only allow main and dev:
allowedrefs=["main","dev"]file.html in the master branch will now be available on file.html in the master branch will now be available on otherfile.html in the dev branch will now be available on otherfile.html in the dev branch will now be available one.g. we'll use the yourrepo repo in the yourorg org and there is a file.html in the master branch and a otherfile.html in the dev branch. The master branch is your default branch.
gitea-pages-allowall topic to the yourrepo repo (this is used to opt-in your repo).file.html in the master branch will now be available on file.html in the master branch will now be available on otherfile.html in the dev branch will now be available on otherfile.html in the dev branch will now be available onAs this is a 3rd party plugin you'll need to build caddy (or use the binaries). To build with this plugin you'll need to have go1.19 installed.
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest #this will install xcaddy in ~/go/bin
~/go/bin/xcaddy build --with github.com/42wim/caddy-gitea@v0.0.4暂无开放 Issues,或尚未同步最近议题。