DEV Community

Fernando Paladini
Fernando Paladini

Posted on

Publish a Ghost Blog to GitHub Pages with a Reusable Workflow

Ghost is pleasant to write in, but hosting the runtime and serving a public blog are different jobs. If you want to keep Ghost local and publish only static files, the ghost-on-github-pages-starter template gives you a small GitHub Actions entry point for that split.

This tutorial walks through the starter's current workflow. You will create a repository from the template, place a Ghost content snapshot under content/, enable GitHub Pages, and let a reusable workflow start Ghost, export static HTML, validate it, and deploy the result.

TL;DR

Use ghost-on-github-pages-starter as the blog repository. Its workflow calls the toolkit's reusable workflow, which runs the official ghost:6 image, uses gssg to export the site, validates the generated files, and deploys a Pages artifact. Keep the Ghost database and themes in content/, but leave .env, SMTP credentials, Stripe keys, and Mailgun keys out of Git.

Prerequisites

You need:

  • A GitHub account with permission to create a repository from a template.
  • A local Ghost installation or Docker-based Ghost setup that contains the content you want to publish.
  • A repository created from the starter template.
  • GitHub Pages configured to use GitHub Actions.

The template itself is MIT licensed. It has no release tag, so this guide targets the public default branch state checked on November 30, 2026. The starter commit used for this article is 87290d5.

1. Create the blog repository

Open the starter repository and select Use this template. Give the new repository a name such as my-ghost-blog.

In the new repository, open Settings, then Pages, and choose GitHub Actions as the source. The workflow needs the repository's Pages and identity-token permissions, which are already declared in the template:

permissions:
  contents: read
  pages: write
  id-token: write
Enter fullscreen mode Exit fullscreen mode

The template is designed for a project site. For a repository named USER.github.io, edit the workflow's production_domain and gh_repo values as described in the template README. Otherwise, the generated address is:

https://USER.github.io/REPO
Enter fullscreen mode Exit fullscreen mode

2. Add the Ghost content snapshot

The starter's content/README.md explains the expected layout. Copy the content you want to publish from your local Ghost directory into the repository's content/ directory. The important paths normally include:

content/data/          # SQLite database, including ghost.db
content/images/       # uploaded images
content/themes/       # active themes
Enter fullscreen mode Exit fullscreen mode

Do not copy .env or payment and email credentials. The upstream toolkit specifically warns against committing SMTP, Stripe, or Mailgun settings. A local SQLite blog without members or payment configuration is enough for this static publishing path.

The workflow checks whether content/ exists. The starter includes that directory, so a first run with only its README can boot Ghost and publish the default welcome page. Replace the README-only content with your real snapshot before treating the public site as your blog.

3. Understand the workflow you are running

The starter's .github/workflows/publish-static.yml passes repository-specific values to a reusable workflow:

jobs:
  publish:
    uses: paladini/ghost-on-github-pages/.github/workflows/publish-static.yml@master
    with:
      production_domain: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
      gh_username: ${{ github.repository_owner }}
      gh_repo: ${{ github.event.repository.name }}
      content_path: content
      deploy_pages: true
Enter fullscreen mode Exit fullscreen mode

The reusable workflow then performs the operational work on Ubuntu. It checks out both repositories, installs ghost-static-site-generator, starts Ghost 6 with Docker Compose, waits for Ghost to answer on port 2373, exports static files with gssg, runs the toolkit's static-site validation, uploads the Pages artifact, and deploys it with the official Pages actions.

This is why the starter contains almost no application code. Your repository owns the content snapshot and the caller workflow. The toolkit repository owns the container setup, export script, validation script, and reusable workflow.

4. Commit and publish

Commit the content snapshot and workflow to main or master, depending on the branch you use:

git add content .github/workflows/publish-static.yml
git commit -m "Publish Ghost content with GitHub Pages"
git push origin main
Enter fullscreen mode Exit fullscreen mode

Open the Actions tab and select Publish static site. A successful run should contain these observable stages:

  1. Ghost starts in the workflow runner.
  2. The content snapshot is mounted into Ghost.
  3. Static HTML is exported for the configured domain.
  4. Generated files pass the toolkit validation.
  5. GitHub Pages receives and deploys the artifact.

Then open the Pages URL from the repository's Deployments or Pages settings. The upstream getting-started guide suggests checking both the local Ghost URL and the public site, including links to posts and tags. Those links are useful because a successful export can still have an incorrect URL configuration.

5. Verify the result instead of trusting the green check

Use this short checklist after the workflow finishes:

  • The Pages deployment has a successful status.
  • The home page loads over HTTPS.
  • A post page loads directly, not only through the home page.
  • Tag links do not redirect to localhost.
  • Images load from the public site.
  • The site URL matches the production_domain passed to the reusable workflow.

For a project site, the template computes production_domain from the repository owner and repository name. For a user site, the README requires a manual edit because https://USER.github.io/USER.github.io would be wrong.

Common failure modes

The workflow cannot find content

The reusable workflow defaults content_path to content and refuses a missing directory unless allow_empty is enabled. Keep the directory in the repository and put the Ghost snapshot inside it. Treat allow_empty: true as an intentional empty-site choice, not as a fix for a missing backup.

The public links point to localhost

The exporter needs the public domain. Check production_domain, gh_username, and gh_repo. A wrong project-versus-user-site choice changes the URL prefix and can make generated links unusable.

Pages deployment is blocked

Confirm that Pages uses GitHub Actions and that the repository accepts the workflow permissions for Pages and the OIDC identity token. The workflow declares pages: write and id-token: write; changing those permissions can prevent deployment.

The site publishes stale posts

The workflow publishes the database and themes found in the committed content/ snapshot. Editing Ghost locally does not change GitHub until you copy the updated content, review the diff, commit it, and push it.

Secrets appear in the content snapshot

Stop the publication, remove the secret from the repository history using an appropriate incident process, rotate it, and inspect Ghost's content settings. The toolkit's warning is concrete: do not commit .env, SMTP keys, or member payment settings.

FAQ

Does GitHub Pages run Ghost?

No. The workflow runs Ghost temporarily in GitHub Actions, exports static files, and deploys those files. GitHub Pages serves the result without running the Ghost application.

Do I need a database server?

Not for this documented path. The toolkit expects a Ghost content snapshot and supports the local SQLite layout described in its CI guide. External services may be needed for features you add to Ghost, such as email delivery or member payments.

Can I publish without committing content?

The reusable workflow can be configured with allow_empty, but the starter's documented workflow is intended for a real content/ snapshot. An empty export is useful for a deliberate test, not for a finished blog.

Is the workflow pinned to a release?

The starter currently calls the toolkit's master branch and has no release tag of its own. That is convenient for updates but less reproducible than pinning a reviewed commit. If you need strict supply-chain repeatability, review the reusable workflow and pin the referenced toolkit revision according to your team's change policy.

Limitations and security boundaries

This setup is a static publishing pipeline, not a complete Ghost hosting service. It does not provide a running admin application, background jobs, member authentication, payment processing, or transactional email on GitHub Pages. The public artifact can also expose anything present in the exported content, so review images, themes, settings, and generated files before pushing.

The starter uses @master for the reusable workflow. That means future changes in the toolkit can affect later runs. Review workflow changes, keep Actions permissions narrow, and avoid putting credentials in the content snapshot. These are operational safeguards, not guarantees that a generated site is secure.

Takeaway

The useful boundary is simple: write and manage content in Ghost locally, commit a reviewed content snapshot, and let GitHub Actions produce the static public artifact. The starter template makes that boundary visible while the toolkit centralizes Docker, export, validation, and Pages deployment.

What would you pin first for a production blog: the reusable workflow commit, the Ghost image version, or the content export itself?

Disclosure: This article was prepared with AI assistance. The repository files, current workflow, public documentation, license, and runnable environment facts were checked against the cited primary sources before publication.

Top comments (0)