Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Easy Ghost content API integration with Nuxt.js.
Nuxt Ghost is a Nuxt.js module that integrates the Ghost content API, allowing Nuxt applications to fetch posts and tags from a headless Ghost CMS. This open-source module, maintained by Gomah, is designed for developers who want to use Ghost as a content backend and Nuxt as the frontend, with support for static site generation and sitemap generation.
Nuxt Ghost is a Nuxt module that connects to the Ghost Content API. To use it, you add nuxt-ghost to the modules array in nuxt.config.js and supply your Ghost URL, Content API key, and an API version (default is v4). The module exports a GhostContentAPI class with methods to browse posts and tags. It also provides a hook for generating static routes for nuxt generate, making it easy to build static blogs or content sites.
nuxt.config.js: include 'nuxt-ghost' in modules and set the ghost property with url, key, and version.GhostContentAPI from nuxt-ghost to fetch posts with posts.browse and tags with tags.browse, including options like limit, order, and include.generate:before event creates routes for every post, blog pagination page, and tag pagination page, so nuxt generate builds all pages./page/2 and subsequent pages based on a configurable perPage value (example uses 3 posts per page).version option.nuxt generate and need all blog and tag URLs pre-rendered into the output.GhostContentAPI client, then display them with custom Vue components.After installing the package and configuring it in your Nuxt project, you can import GhostContentAPI directly in your code. The route-generation hook lives in a custom module file you create under modules/. In that file, you instantiate the API with your Ghost settings, fetch all posts and tags, and build an array of routes. This array is assigned to generateOptions.routes. The hook also checks if nuxt.sitemap exists and appends the routes there.
Yes, nuxt-ghost is open-source and released under the MIT License, so it is free to use and modify.
The default version is v4, and it can be changed via the version option in the Ghost module configuration.
Use the provided hook in a custom module file inside modules/. The hook fetches all posts and tags, then adds routes for each post, blog pagination pages, and tag pagination pages to generateOptions.routes.
Yes, you can import GhostContentAPI directly in your Nuxt app to query Ghost content at runtime or during server-side rendering.
Yes, the example hook checks if nuxt.sitemap exists and merges the generated routes into the sitemap's route list.
