Static site hosting for code.mehalter.com
What is this?
This service provides automated static site hosting for repositories
hosted on
code.mehalter.com. It can watch for updates to your repository's
pages branch and serves them globally, or can be pushed to
directly using Forgejo Actions.
Using the shared mehalter.page domain
You can host your site directly under your username using the following URLs:
-
Root site: If your repository is named
{username}.mehalter.page, use the URLhttps://{username}.mehalter.page/. -
Project site: For any other repository name, use the
URL
https://{username}.mehalter.page/{repository}/.
Deploying using repository webhooks
To set this up via webhooks (Repository Settings > Webhooks > Add Webhook > Forgejo), use the following settings:
-
Target URL: The URL as described above, e.g.
https://{username}.mehalter.page/{repository}/ - HTTP method:
POST - Content Type:
application/json - Branch Filter: Set this to
pages.
pages in
your repository.
Deploying with Forgejo Actions
Using a Forgejo Actions workflow allows you to build your site and push the files to the pages server automatically using your internal forge token.
Example Workflow (.forgejo/workflows/deploy.yaml)
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# Add your build steps here (e.g., Hugo, Vite, or Zola)
- name: Publish to Pages
uses: https://code.forgejo.org/actions/git-pages@v2
with:
# Specify domain (just use repository name for root domain):
site: https://${{ forge.repository_owner }}.mehalter.page/${{ forge.event.repository.name }}
server: mehalter.page
# Use the built-in token for authentication
token: ${{ forge.token }}
# Specify directory of built site
source: public/
Using your own custom domain
To use mehalter.page to host a website on a domain you own (e.g.,
example.com) using one of the methods below:
Important: If you are using Cloudflare to manage your domain's DNS records, make sure every DNS record for mehalter.page is set to DNS only (a gray cloud). This ensures that mehalter.page can properly handle everything necessary such as SSL certificate generation and redirects.
Deploying using repository webhooks
- Contact the Administrator: Reach out to the server admin to have the appropriate routes configured for your domain.
-
Configure DNS: Configure your domain to have
A/AAAArecords pointing to the same server asmehalter.page. In most cases this can be done using anALIASrecord, but if this functionality isn't available it will need to be done by hand. -
Verify Ownership: Prove control of the domain by adding
a
TXTDNS record at the_git-pages-repositorysubdomain with the content of your full repository clone urlhttps://code.mehalter.com/{username}/{repository}.git. - Configure Webhooks: Add a webhook to your repository to deploy your site (as shown below).
-
Push Website: Push your built website to a branch named
pagesin your repository.
To set this up via webhooks (Repository Settings > Webhooks > Add Webhook > Forgejo), use the following settings:
-
Target URL: Your custom URL, e.g.
example.com - HTTP method:
POST - Content Type:
application/json - Branch Filter: Set this to
pages.
Important: The initial push must use
http:// in order to trigger the generation of valid SSL
certificates. If you want to avoid this, you can execute the following to
do the initial deployment which requires content in a
pages branch of the repository:
curl https://mehalter.page/ -X PUT -H "Host: {domain}" --data
"https://code.mehalter.com/{user}/{repo}.git"
Deploying with Forgejo Actions
- Contact the Administrator: Reach out to the server admin to have the appropriate routes configured for your domain.
-
Configure DNS: Configure your domain to have
A/AAAArecords pointing to the same server asmehalter.page. In most cases this can be done using anALIASrecord, but if this functionality isn't available it will need to be done by hand. -
Verify Ownership: Prove control of the domain by adding
a
TXTDNS record at the_git-pages-challengesubdomain (use the generator below). -
Store password as repository secret: Store the password
as a repository secret named
PAGES_PASSWORD. - Configure Actions: Add a Forgejo Actions workflow to your repository to deploy your site (as shown below).
Important: Keep your password secret. Anyone with this password can replace your site content.
Example Workflow (.forgejo/workflows/deploy.yaml)
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# Add your build steps here (e.g., Hugo, Vite, or Zola)
- name: Publish to Pages
uses: https://code.forgejo.org/actions/git-pages@v2
with:
# Specify your custom domain:
site: https://example.com
server: mehalter.page
# Use the saved password secret
password: ${{ secrets.PAGES_PASSWORD }}
# Specify directory of built site
source: public/
Important: The initial push must use
http:// in order to trigger the generation of valid SSL
certificates. If you want to avoid this, you can execute the following to
do the initial deployment which requires content in a
pages branch of the repository:
curl https://mehalter.page/ -X PUT -H "Host: {domain}" -H
"Authorization: Pages {password}" --data
"https://code.mehalter.com/{user}/{repo}.git"
How do I unpublish my site?
There are two ways to remove your site from the server:
-
Push an empty commit: This makes all contents unreachable and erases routing information. Run the following commands in your terminal:
git checkout --orphan empty-pages && \ git rm --cached -rf . && \ git commit --allow-empty -m "unpublish" && \ git push -f origin empty-pages:pages -
Use a DELETE request: If you have a custom domain with a password, you can unpublish via Curl:
curl https://{domain}/ -X DELETE -H "Authorization: Pages {password}"