/ ghost


0.75 lts/argon -> v4.8.6
0.11 lts/boron -> v6.12.0

API docs: http://api.ghost.org
Theme docs: http://themes.ghost.org
Get helper: http://themes.ghost.org/docs/get
ajax: http://themes.ghost.org/docs/ghost-api-ajax

Ghost 快捷手册

中文 tag 的支持

ghost fonts.gstatic.com


NODE_ENV=production npm start


更换主题可能需要重启 ghost 一次,才能看到新主题

$ docker pull ghost
$ docker run -d --name some-ghost -p 3001:2368 ghost



Then, access it via http://localhost:3001 or http://host-ip:3001 in a browser.

RESTful api

Ghost is built on top of a RESTful JSON API. This API is used for all data access inside of the Ghost software itself, meaning the API is the heart of the software, not an afterthought or additional layer.

  • Public API ,需要配置 domain 白名单。
  • Private API,提要提供 credentials。

Ghost API

ghost 1.17 调用方式: https://example.com/ghost/api/v0.1/posts/

调用 public api 的 3 种方式:

  • jQuery.ajax
  • Internal
  • Handlebars

Ajax calls from an external website form Ghostv0.11.9

This recipe is for you, if you have a blog located on a subdomain or subdirectory of your site and want to pull data into a different site. E.g. Your blog lives at blog.mysite.com and you want to list out the 3 most recent blog posts on www.mysite.com.

step1.Granting access to your domain

Once you have the Public API enabled(默认不启用), you need to add your domain to the list of trusted domains so that it is allowed to request data from the API.


sqlite3 content/data/ghost.db
select * from clients;

You need the id from the row containing the "Ghost Frontend" client.

Now, we need to add a new domain to the client_trusted_domains table. The columns for this table are id, client_id, and trusted_domain.

  • id - The unique number of the row in the list of client_trusted_domains table
  • uuid - A globally unique identifier, you can get one by visiting https://www.uuidgenerator.net/.
  • client_id: - ID of the client who will be doing the access, in our case ghost-frontend
  • trusted_domain: The url of the domain doing the accessing. This must include the protocol and must not end in a trailing slash. If you need support for more than one protocol or subdomain, each one will need its own entry.

For example, if the id of the ghost-frontend client is 2, and I want to make requests from https://www.mysite.com, then the query should be:

insert into client_trusted_domains (uuid, client_id, trusted_domain) values ('7137d1e7-5692-47ef-9dfa-bb8ca3fa2db6', 2, 'https://www.mysite.com');
select * from client_trusted_domains;

If it got inserted correctly, go ahead and log out of sqlite and re-start your Ghost blog.

step2.Adding the Ghost SDK to your site

Next, we will include the ghost-sdk.js to get access to the Ghost api url (ghost.url.api()) utility, which dynamically generates correctly formatted URLs for you.

打开博客 http://blog.mysite.com 页面,右键查看源代码,在
head 中找到:

<script type="text/javascript" src="/shared/ghost-url.min.js"></script>
<script type="text/javascript">
  clientId: "ghost-frontend",
  clientSecret: "<letters-and-numbers>"


#输出: //haobing.wang/ghost/api/v0.1/?client_id=ghost-frontend&client_secret=fdbc77c87611

将这段代码复制粘贴到 https://www.mysite.com 中,并在 js 文件前补全 ghost 的域名:/shared/ghost-url.min.js => https://blog.mysite.com/shared/ghost-url.min.js

<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

<script type="text/javascript" src="https://blog.mysite.com/shared/ghost-url.min.js"></script>
<script type="text/javascript">
  clientId: "ghost-frontend",
  clientSecret: "<letters-and-numbers>"
function onSuccess(data) {
  var $result = $('#blog-posts');
  $.each(data.posts, function (i, post) {
      '<li>' + post.title + '</li>'

jQuery(document).ready(function () {
    ghost.url.api('posts', {limit: 3})

Ajax calls from an external website from Ghost 1.10.x


在主题中访问 public api