
Prerequisites
You’ll need basic understanding of JavaScript and a running Ghost installation, which can either be self-hosted or using Ghost(Pro). In this documentation we’re going to start with a new project from scratch. Skip these initial setup steps if you have an existing VuePress project. Firstly, create a new project:package.json
:
Getting started
Since VuePress uses Markdown files, you’ll need to create a script that uses the Ghost Content API and creates Markdown files from your content.Exposing and converting content
The following script gives you a good starting point as well as an idea of what’s possible. This is a minimal working version and does not cover:- removing deleted/unpublished posts.
- renaming or skipping frontmatter properties.
js-yaml
will create yaml frontmatter and fs-extra
will place the Markdown files in the right directories.
To start, create a new file in the root directory of your project:
url
value to the URL of your Ghost site. For Ghost(Pro) customers, this is the Ghost URL ending in .ghost.io
, and for people using the self-hosted version of Ghost, it’s the same URL used to access your site.
Next, update the key
value to a key associated with the Ghost site. A key can be provided by creating an integration within the Ghost Admin. Navigate to Integrations and click “Add new integration”. Name the integration appropriately and click create.

moment.js
to include a formatted date in the filename like so:
Caveats
In some rare cases posts containing code blocks can be parsed incorrectly. A workaround for that is to convert the HTML into Markdown by using a transformer, such as Turndown. Transforming the content will result in the loss of some formatting, especially when you’re using a lot of custom HTML in your content, but gives you plenty of customizing options to render the code blocks correctly. To use Turndown, add it as a dependency:Programmatically create a sidebar
VuePress comes with a powerful default theme that supports a lot of things “out of the box”™️, such as integrated search and sidebars. In this section we’re going to add a sidebar to the home page by reading the filenames of the saved Markdown files. As a first step, we need to create an index page in the root of the project:sidebarDepth
property tells VuePress that we want to render subheadings from h1
and h2
headings from our Ghost content. You can find more information about the default theme config here.
The next step is to create a VuePress config.js
file in a directory called .vuepress/
:
fs
and path
modules from VuePress’ shared utils and add a new getSidebar()
function as shown below:

Next steps
Discover how to create a component to list all posts on the index page of your VuePress site, or how to create files for tags and authors in our recipes on the next page. For further information, check out the Ghost Content API documentation and the official VuePress documentation.Examples
The flexibility of the Ghost Content API allows you to feed posts, pages and any other pieces of content from your Ghost site into a VuePress front-end. Below are a few popular examples of how to customise your site. If you just landed here, check out Working With VuePress for more context!Post list component
Components live in a.vuepress/components/
folder. Create this folder structure and make a new file in components
called PostList.vue
. In that file add a <template>
element add the following to list all of the posts:
<template>
element, add a <script>
element, which will contain queries that will in turn pass data to the <template>
above:
index.md
file like this:
