
Eleventy and Ghost
Eleventy is a good fit for a lightweight Ghost front-end. Ghost remains the CMS: editors write posts, manage pages, upload images, and handle publishing in Ghost Admin. Eleventy reads that content from the Content API when the site builds. For most Eleventy sites, use the official JavaScript Content API client. It is maintained as part of the TryGhost SDK and works in Node.js during Eleventy builds. Use the Admin API only for private server-side scripts, such as imports or custom publishing tools. Do not put an Admin API key in client-side JavaScript.Prerequisites
This configuration requires basic knowledge of JavaScript and HTML templates. You will also need:- A running Ghost site, either self-hosted or on Ghost(Pro)
- A custom integration in Ghost Admin so you can copy the Content API URL and key
- An Eleventy project
Start from a new Eleventy site
If you already have an Eleventy site, skip to the Content API setup. Otherwise, create a small project and install Eleventy:Install the Ghost Content API client
If you started with an existing Eleventy site, install the Ghost Content API client:.env file is fine if your deployment platform loads it and you keep it out of source control.
.ghost.io URL. For self-hosted Ghost, use the public URL for your Ghost install.
Fetch Ghost content with a global data file
Eleventy global data files make API data available to every template. Create_data/ghost.js:
meta.pagination.next value until there are no more pages. See pagination for building static sites and Content API pagination for the underlying API behavior.
List posts on the home page
Createindex.njk and read from the ghost data object:
Create one page per post
Use Eleventy pagination with a page size of1 to create a static page for every Ghost post.
safe filter is normal for a trusted CMS source, but do not use it for untrusted user-submitted HTML.
Create tag and author pages
The sameghost data object includes tags and authors. For example, this creates one archive page per tag:
_data/ghost.js so templates do less filtering work.
Run Eleventy locally
Once the data file and templates are in place, start Eleventy’s local development server:http://localhost:8080/ by default.
Use the Admin API from private scripts
The Admin API can create, update, and publish content. It is useful for migrations or custom editorial tooling, but it is not needed to render a public Eleventy front-end. Install the Admin API client only where the key stays private:GHOST_ADMIN_API_KEY to the browser.

