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:

Deploying using repository webhooks

To set this up via webhooks (Repository Settings > Webhooks > Add Webhook > Forgejo), use the following settings:

Then simply push your built website to branch named 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

  1. Contact the Administrator: Reach out to the server admin to have the appropriate routes configured for your domain.
  2. Configure DNS: Configure your domain to have A/AAAA records pointing to the same server as mehalter.page. In most cases this can be done using an ALIAS record, but if this functionality isn't available it will need to be done by hand.
  3. Verify Ownership: Prove control of the domain by adding a TXT DNS record at the _git-pages-repository subdomain with the content of your full repository clone url https://code.mehalter.com/{username}/{repository}.git.
  4. Configure Webhooks: Add a webhook to your repository to deploy your site (as shown below).
  5. Push Website: Push your built website to a branch named pages in your repository.

To set this up via webhooks (Repository Settings > Webhooks > Add Webhook > Forgejo), use the following settings:

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

  1. Contact the Administrator: Reach out to the server admin to have the appropriate routes configured for your domain.
  2. Configure DNS: Configure your domain to have A/AAAA records pointing to the same server as mehalter.page. In most cases this can be done using an ALIAS record, but if this functionality isn't available it will need to be done by hand.
  3. Verify Ownership: Prove control of the domain by adding a TXT DNS record at the _git-pages-challenge subdomain (use the generator below).
  4. Store password as repository secret: Store the password as a repository secret named PAGES_PASSWORD.
  5. 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:

  1. 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
  2. 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}"