### Install Ghost CLI: Basic and Versioned Commands Source: https://docs.ghost.org/ghost-cli Demonstrates how to install Ghost using the Ghost-CLI, including specifying a version, installing locally for development, and using version/local flags together. This command automates environment checks, setup, and starting the Ghost instance. ```bash # Install a specific version (1.0.0 or higher) ghost install [version] # Install version 2.15.0 ghost install 2.15.0 # Install locally for development ghost install local # Install version 2.15.0, locally for development ghost install 2.15.0 --local ``` -------------------------------- ### Install Hexo CLI Source: https://hexo.io/ Installs the Hexo command-line interface globally using npm. This is the first step to start using Hexo for your blog. ```bash npm install hexo-cli -g ``` -------------------------------- ### Initialize and Run a Hexo Blog Source: https://hexo.io/ Demonstrates the basic commands to initialize a new Hexo blog, install its dependencies, and start the development server. ```bash hexo init blog cd blog npm install hexo server ``` -------------------------------- ### Ghost Install Command Source: https://docs.ghost.org/ghost-cli The primary command for setting up a production-ready Ghost installation. It handles Nginx, MySQL, and systemd configuration, guiding the user through setup questions for a complete deployment. ```bash ghost install ``` -------------------------------- ### Start Stripe CLI Listener Source: https://docs.ghost.org/webhooks This command initiates the Stripe CLI to listen for webhook events and forward them to a local Ghost instance. Ensure the port number matches your Ghost installation. It requires the Stripe CLI to be installed and logged in. ```bash stripe listen --forward-to http://localhost:2368/members/webhooks/stripe/ ``` -------------------------------- ### Install Ghost CLI: Options for Customization Source: https://docs.ghost.org/ghost-cli Explains various options for the `ghost install` command, allowing customization of the installation process. These include setting development mode, specifying installation directory, installing from archives, disabling checks, and controlling setup/start behaviors. ```bash # Get more information before running the command ghost install --help # Install in development mode for a staging env ghost install --development, ghost install -D # Select the directory to install Ghost in ghost install --dir path/to/dir # Install Ghost from a specific archive (useful for testing or custom builds) ghost install --archive path/to/file.tgz # Disable stack checks ghost install --no-stack # Install without running setup ghost install --no-setup # Install without starting Ghost ghost install --no-start # Tells the process manager not to restart Ghost on server reboot ghost setup --no-enable # Install without prompting (disable setup, or pass all required parameters as arguments) ghost install --no-prompt ``` -------------------------------- ### Install and Verify BeeHiiv to Ghost Migration CLI Source: https://docs.ghost.org/migration/beehiiv This section provides the commands to install the `@tryghost/migrate` CLI globally using npm and then verify that the installation was successful by running the `migrate` command. ```shell # Install CLI npm install --global @tryghost/migrate # Verify it's installed migrate ``` -------------------------------- ### Updating a Self-Hosted Ghost Installation Source: https://context7_llms This guide explains the process of updating a self-hosted Ghost installation to the latest version, ensuring you have the most recent features and security patches. ```Shell ghost update ``` -------------------------------- ### Install and Run Eleventy Source: https://11ty.io/ Instructions for installing Node.js, creating an initial Markdown file, and running Eleventy with the development server. Requires Node.js version 18 or newer. ```Bash node --version ``` ```Bash echo '# Heading' > index.md ``` ```Bash echo '# Heading' | out-file -encoding utf8 'index.md' ``` ```Bash echo '# Heading' | npx @11ty/create index.md ``` ```Bash npx @11ty/eleventy --serve ``` ```Bash pnpm dlx @11ty/eleventy --serve ``` ```Bash yarn dlx @11ty/eleventy --serve ``` -------------------------------- ### Ghost CLI Command Help Source: https://docs.ghost.org/ghost-cli Displays a list of available Ghost CLI commands and their brief descriptions. This is useful for discovering functionalities and understanding command options. You can also get detailed help for specific commands like `ghost install --help`. ```bash ghost help ``` -------------------------------- ### Ghost Install Local Command Source: https://docs.ghost.org/ghost-cli Installs Ghost in development mode using SQLite3 and a local process manager. This is suitable for local development environments and is an alternative to a full production setup. ```bash ghost install local ``` -------------------------------- ### Ghost Setup CLI: Stage-Specific Commands Source: https://docs.ghost.org/ghost-cli Details the commands for running specific stages of the `ghost setup` process individually. This allows for granular control over server configuration, including MySQL user creation, Nginx setup, SSL configuration, and database migration. ```bash # Run ghost setup with specific stages ghost setup [stages...] # Creates a new mysql user with minimal privileges ghost setup mysql # Creates an nginx configuration file in `./system/files/` and adds a symlink to `/etc/nginx/sites-enabled/` ghost setup nginx # Creates an SSL service for Ghost ghost setup ssl # Create an nginx and ssl setup together ghost setup nginx ssl # Creates a low-privileged linux user called `ghost` ghost setup linux-user # Creates a systemd unit file for your site ghost setup systemd # Runs a database migration ghost setup migrate ``` -------------------------------- ### Ghost Installation and Hosting Source: https://context7_llms Information regarding the installation process, hosting recommendations, and migration options for Ghost publications. ```APIDOC ## Ghost Installation and Hosting ### Description This section provides guidance on how to install and host a Ghost publication, along with information on migrating existing content to Ghost. ### Key Topics - **How To Install Ghost:** - **Description:** Recommended methods for getting started with Ghost, including options for Ghost(Pro) and self-hosted instances. Details server requirements (e.g., Ubuntu with 1GB memory). - **Reference:** [https://docs.ghost.org/install.md](https://docs.ghost.org/install.md) - **Hosting Ghost:** - **Description:** A guide focused on running Ghost in production environments and setting up publications for scalability. - **Reference:** [https://docs.ghost.org/hosting.md](https://docs.ghost.org/hosting.md) - **Migrating To Ghost:** - **Description:** Resources and instructions for migrating content from other platforms to Ghost. - **Reference:** [https://docs.ghost.org/migration.md](https://docs.ghost.org/migration.md) ``` -------------------------------- ### Install @tryghost/helpers (npm/yarn) Source: https://docs.ghost.org/content-api/javascript Install the @tryghost/helpers package using npm or yarn. This package provides various utility functions for Ghost. ```bash yarn add @tryghost/helpers ``` ```bash npm install @tryghost/helpers ``` -------------------------------- ### Include Examples Source: https://docs.ghost.org/content-api/parameters Examples demonstrating how to use the `include` parameter for different resource types. ```APIDOC ## Include Examples ### Description Examples of using the `include` parameter to retrieve related data. ### Query Examples - **Posts & Pages:** - `&include=authors` - Returns posts/pages with expanded author data (`authors` array and `primary_author`). - `&include=tags` - Returns posts/pages with expanded tag data (`tags` array and `primary_tag`). - `&include=authors,tags` - Combines multiple includes. - **Authors:** - `&include=count.posts` - Returns author data with a count of their associated posts. - **Tags:** - `&include=count.posts` - Returns tag data with a count of associated posts. - **Tiers:** - `&include=monthly_price,yearly_price,benefits` - Returns tier data including pricing and benefit details. ``` -------------------------------- ### Content API JavaScript Client - Installation Source: https://docs.ghost.org/content-api/javascript Instructions for installing the @tryghost/content-api package using npm or yarn. ```APIDOC ## Content API JavaScript Client - Installation ### Description Install the official Ghost Content API JavaScript client library into your project using your preferred package manager. ### Method N/A (Package Installation) ### Endpoint N/A ### Parameters N/A ### Request Example Using npm: ```bash npm install @tryghost/content-api ``` Using yarn: ```bash yarn add @tryghost/content-api ``` ### Response N/A (Installation command output) #### Response Example N/A ``` -------------------------------- ### Fetch and Format Tier Data with Get Helper Source: https://docs.ghost.org/themes/helpers/data/tiers Use the `{{#get}}` helper to fetch tier data, including monthly price, yearly price, and benefits. The example shows how to loop through fetched tiers and display their names and prices, with links for signup. ```handlebars {{! Get all tiers with monthly price, yearly price, and benefits data }} {{#get "tiers" include="monthly_price,yearly_price,benefits" limit="100" as |tiers|}} {{! Loop through our tiers collection }} {{#foreach tiers}} {{name}} {{#if monthly_price}}
Monthly – {{price monthly_price currency=currency}}
{{/if}} {{#if benefits}} {{#foreach benefits as |benefit|}} {{benefit}} {{/foreach}} {{/if}} {{/foreach}} {{/get}} ``` -------------------------------- ### Output Prices for All Tiers with Ghost Price Helper Source: https://docs.ghost.org/themes/helpers/data/price This example demonstrates how to loop through a collection of pricing tiers and display the monthly and yearly prices for each tier, formatted using the `price` helper. It utilizes the `get` and `foreach` helpers to iterate over tier data. ```handlebars {{#get "tiers" include="monthly_price,yearly_price,benefits" limit="100" as |tiers|}} {{! Loop through our tiers collection }} {{#foreach tiers}} {{#if monthly_price}}
Monthly – {{price monthly_price currency=currency}}
{{/if}} {{#if yearly_price}}
Monthly – {{price yearly_price currency=currency}}
{{/if}} {{/foreach}} {{/get}} ``` -------------------------------- ### Ghost Config Application Options Source: https://docs.ghost.org/ghost-cli Lists common application-level configuration options that can be passed to `ghost config`, `ghost install`, or `ghost setup`. These options control the site's URL, admin URL, port, IP, and log output. ```bash # URL of the site including protocol --url https://mysite.com # Admin URL of the site --admin-url https://admin.mysite.com # Port that Ghost should listen on --port 2368 # IP to listen on --ip 127.0.0.1 # Transport to send log output to --log ["file","stdout"] ``` -------------------------------- ### Install @tryghost/string (npm/yarn) Source: https://docs.ghost.org/content-api/javascript Install the @tryghost/string package using npm or yarn. This package contains utilities for string manipulation. ```bash yarn add @tryghost/string ``` ```bash npm install @tryghost/string ``` -------------------------------- ### Order Posts by Date and Title with {{#get}} Source: https://docs.ghost.org/themes/helpers/functional/get This example shows how to order retrieved posts using the 'order' attribute within the {{#get}} helper. It illustrates fetching the oldest posts by 'published_at asc' and ordering posts alphabetically by 'title asc'. ```handlebars {{! Get the 5 oldest posts }} {{#get "posts" limit="5" order="published_at asc"}}{{/get}} {{! Get posts in alphabetical order by title }} {{#get "posts" limit="5" order="title asc"}}{{/get}} ``` -------------------------------- ### Dynamic Newsletter Subscription Form Source: https://docs.ghost.org/themes/helpers/functional/get This example creates a dynamic sign-up form for newsletters. It uses the {{#get}} helper to fetch available newsletters and allows users to subscribe to specific ones via checkboxes. ```handlebars {{! Create a dynamic sign-up form that allows members to subscribe to specific newsletters}}
{{#get "newsletters"}} {{#foreach newsletters}} {{else}} {{/get}}
``` -------------------------------- ### Working Example: Fetching and Logging Posts Source: https://docs.ghost.org/content-api/javascript A complete example demonstrating the initialization of the Ghost Content API client and fetching posts with a specific filter, then logging their titles. Includes error handling. ```javascript const api = new GhostContentAPI({ host: 'https://demo.ghost.io', key: '22444f78447824223cefc48062', version: "v6.0" }); // fetch 5 posts, including related tags and authors api.posts.browse({ filter: 'tag:fiction+tag:-fables' }) .then((posts) => { posts.forEach((post) => { console.log(post.title); }); }) .catch((err) => { console.error(err); }); ``` -------------------------------- ### Start Ghost with Webhook Secret Source: https://docs.ghost.org/webhooks This command starts the local Ghost instance with the Stripe webhook secret. The secret is obtained after running the `stripe listen` command and is crucial for authenticating webhook events from Stripe. This setup enables local testing of Stripe-integrated features. ```bash WEBHOOK_SECRET=whsec_1234567890abcdefg ghost start ``` -------------------------------- ### Retrieve and Order Tags by Post Count Source: https://docs.ghost.org/themes/helpers/functional/get This example illustrates fetching all tags and ordering them based on their associated post count using the 'include' and 'order' attributes of the {{#get}} helper. It displays the tag name and its post count. ```handlebars {{! Get all tags and order them by post count }} {{#get "tags" limit="100" include="count.posts" order="count.posts desc"}} {{#foreach tags}}

{{name}} ({{count.posts}})

{{/foreach}} {{/get}} ``` -------------------------------- ### Running VuePress Development Server Source: https://docs.ghost.org/jamstack/vuepress Command to start the VuePress development server. This allows you to preview your site locally as you make changes. ```bash yarn dev ``` -------------------------------- ### Filter Posts by Publication Date (Handlebars) Source: https://docs.ghost.org/themes/helpers/functional/get Shows how to filter posts based on their publication date using the `filter` attribute in the `get` helper. This example retrieves posts published before the current post's publication date, excluding the current post itself. ```handlebars {{#post}} {{#get "posts" filter="published_at:<='{{published_at}}'+id:-{{id}}" limit="3"}} ... {{/get}} {{/post}} ``` -------------------------------- ### Eleventy Output Example Source: https://11ty.io/ Example of Eleventy's console output when building a site, indicating the files being written and the server status. Shows the default output directory `_site` and the development server address. ```Bash [11ty] Writing _site/index.html from ./index.md (liquid) [11ty] Wrote 1 file in 0.03 seconds (v3.1.2) [11ty] Watching… [11ty] Server at http://localhost:8080/ ``` -------------------------------- ### Running Ghost in Production Environment (Bash) Source: https://docs.ghost.org/config This command starts the Ghost application in production mode. It's essential for public-facing websites to ensure optimal performance and security. It requires Node.js to be installed. ```bash NODE_ENV=production node index.js ``` -------------------------------- ### Filter Tiers by Visibility (Public/None) (Handlebars) Source: https://docs.ghost.org/themes/helpers/functional/get Details how to filter tiers based on their visibility setting in Portal. This example retrieves 'public' tiers, with 'none' being another possible filter value. ```handlebars {{! Only get tiers that are public}} {{#get "tiers" filter="visibility:public"}} {{#foreach tiers}}

{{name}}

{{/foreach}} {{/get}} ``` -------------------------------- ### Content API JavaScript Client - Working Example Source: https://docs.ghost.org/content-api/javascript Demonstrates how to initialize the client and fetch posts with their associated tags and authors. ```APIDOC ## Content API JavaScript Client - Working Example ### Description This example shows how to instantiate the Ghost Content API client and perform a basic query to retrieve a list of posts, including their related tags and authors. ### Method N/A (Client-side JavaScript) ### Endpoint N/A (Client-side JavaScript) ### Parameters N/A ### Request Example ```javascript const api = new GhostContentAPI({ url: 'https://demo.ghost.io', key: 'YOUR_CONTENT_API_KEY', version: "v6.0" }); api.posts .browse({ limit: 5, include: 'tags,authors' }) .then((posts) => { posts.forEach((post) => { console.log(post.title); }); }) .catch((err) => { console.error(err); }); ``` ### Response #### Success Response (200) An array of post objects, where each post may include nested `tags` and `authors` arrays if requested. #### Response Example ```json [ { "id": "post_id_1", "title": "Example Post Title 1", "slug": "example-post-title-1", "tags": [ { "id": "tag_id_1", "name": "Example Tag 1" } ], "authors": [ { "id": "author_id_1", "name": "Example Author 1" } ] } // ... more posts ] ``` ``` -------------------------------- ### Specifying Author Range with {{authors}} Source: https://docs.ghost.org/themes/helpers/data/authors Allows outputting a specific range of authors using 'from' and 'to' attributes. 'to' overrides 'limit'. This example outputs authors starting from the second one. ```handlebars {{authors from="2"}} ``` -------------------------------- ### Developer Migration: Custom JSON Export for Ghost Source: https://context7_llms Guides developers on creating a custom JSON export for migrating content to Ghost when no direct export tools exist. The output JSON must not contain comments. A full example is provided in the documentation. ```json { "posts": [ { "title": "Example Post Title", "content": { "rendered": "

This is the HTML content of the post.

" }, "published_at": "2023-10-27T10:00:00Z", "tags": ["example", "migration"] } ], "authors": [ { "name": "John Doe", "slug": "john-doe", "email": "john.doe@example.com" } ] } ``` -------------------------------- ### Install Turndown for HTML to Markdown Conversion (Bash) Source: https://docs.ghost.org/jamstack/vuepress Installs the Turndown library using yarn, which is used to transform HTML content into Markdown. This is particularly useful for correctly rendering code blocks from Ghost posts. ```bash yarn add turndown ``` -------------------------------- ### Run Ghost Doctor Diagnostics Source: https://docs.ghost.org/ghost-cli The 'ghost doctor' command diagnoses potential issues with a Ghost installation. It can check specific aspects like startup configurations or setup success. Running it manually helps identify and resolve problems before they impact the site. ```bash ghost doctor startup ghost doctor setup ``` -------------------------------- ### Initialize Ghost Content API Instance (JavaScript) Source: https://docs.ghost.org/jamstack/next Creates an instance of the Ghost Content API using your Ghost site's URL, API key, and API version. Ensure you replace the placeholder values with your actual credentials. ```javascript // lib/posts.js - or make a separate file to reuse for other resources import GhostContentAPI from "@tryghost/content-api"; // Create API instance with site credentials const api = new GhostContentAPI({ url: 'https://demo.ghost.io', key: '22444f78447824223cefc48062', version: "v6.0" }); ``` -------------------------------- ### Install Dependencies for Ghost Content Export Source: https://docs.ghost.org/jamstack/vuepress This command installs the necessary packages to interact with the Ghost Content API, handle YAML frontmatter, and manage file system operations. These are essential for the script's functionality. ```bash yarn add @tryghost/content-api js-yaml fs-extra ``` -------------------------------- ### Generate JWT Token and Make API Request (JavaScript) Source: https://docs.ghost.org/admin-api This Node.js example manually generates a JWT token using the 'jsonwebtoken' library and makes an API request with 'axios'. It requires installing 'jsonwebtoken' and 'axios'. The token is signed with HS256 using the provided API key and secret. ```javascript // Create a token without the client const jwt = require('jsonwebtoken'); const axios = require('axios'); // Admin API key goes here const key = 'YOUR_ADMIN_API_KEY'; // Split the key into ID and SECRET const [id, secret] = key.split(':'); // Create the token (including decoding secret) const token = jwt.sign({}, Buffer.from(secret, 'hex'), { keyid: id, algorithm: 'HS256', expiresIn: '5m', audience: `/admin/` }); // Make an authenticated request to create a post const url = 'http://localhost:2368/ghost/api/admin/posts/'; const headers = { Authorization: `Ghost ${token}` }; const payload = { posts: [{ title: 'Hello World' }] }; axios.post(url, payload, { headers }) .then(response => console.log(response)) .catch(error => console.error(error)); ``` -------------------------------- ### Configure .env File for Ghost API Source: https://docs.ghost.org/jamstack/eleventy This YAML snippet shows the essential variables in the .env file to configure the Eleventy Starter for Ghost to source content from a specific Ghost site. It includes the Ghost API URL, Content API Key, and the site's local URL for development. ```yaml GHOST_API_URL=https://eleventy.ghost.io GHOST_CONTENT_API_KEY=5a562eebab8528c44e856a3e0a SITE_URL=http://localhost:8080 ``` -------------------------------- ### Define Custom Theme Setting with Description in package.json Source: https://docs.ghost.org/themes/custom-settings This JSON example illustrates defining a 'text' type custom theme setting in `package.json`, including a 'description' field. This description appears in Ghost Admin to guide site owners on the setting's purpose. Setting keys must be lowercase and use snake_case. ```json { "config": { "custom": { "cta_text": { "type": "text", "default": "Sign up for more like this", "group": "post", "description": "Used in a large CTA on the homepage and small one on the sidebar as well" } } } } ``` -------------------------------- ### Install Ghost Content API Helper (Yarn) Source: https://docs.ghost.org/jamstack/hexo Installs the official JavaScript Ghost Content API helper using Yarn. This is a prerequisite for interacting with the Ghost Content API from a Node.js environment like Hexo. ```bash yarn add @tryghost/content-api ``` -------------------------------- ### Initialize Ghost Content API Client (JavaScript) Source: https://docs.ghost.org/jamstack/hexo Initializes the Ghost Content API client with necessary credentials. Requires the Ghost site URL and an API key obtained from Ghost Admin. The version specifies the API version to use. ```javascript const ghostContentAPI = require("@tryghost/content-api"); const api = new ghostContentAPI({ url: 'https://demo.ghost.io', key: '22444f78447824223cefc48062', version: "v6.0" }); ``` -------------------------------- ### Install and Update Ghost CLI Source: https://docs.ghost.org/ghost-cli Installs or updates the Ghost-CLI to the latest version globally using npm. This command is essential for managing your Ghost installation. ```bash sudo npm install -g ghost-cli@latest ``` -------------------------------- ### Example JSON Response for Site Settings Source: https://docs.ghost.org/content-api/settings This is an example of the JSON response structure returned by the /content/settings/ endpoint. It includes various site configuration details such as title, description, logo, social media links, navigation menus, and meta information. ```json { "settings": { "title": "Ghost", "description": "The professional publishing platform", "logo": "https://docs.ghost.io/content/images/2014/09/Ghost-Transparent-for-DARK-BG.png", "icon": "https://docs.ghost.io/content/images/2017/07/favicon.png", "accent_color": null, "cover_image": "https://docs.ghost.io/content/images/2019/10/publication-cover.png", "facebook": "ghost", "twitter": "@tryghost", "lang": "en", "timezone": "Etc/UTC", "codeinjection_head": null, "codeinjection_foot": "", "navigation": [ { "label": "Home", "url": "/" }, { "label": "About", "url": "/about/" }, { "label": "Getting Started", "url": "/tag/getting-started/" }, { "label": "Try Ghost", "url": "https://ghost.org" } ], "secondary_navigation": [], "meta_title": null, "meta_description": null, "og_image": null, "og_title": null, "og_description": null, "twitter_image": null, "twitter_title": null, "twitter_description": null, "members_support_address": "noreply@docs.ghost.io", "url": "https://docs.ghost.io/" } } ```