### Enable Corepack and Run Setup Source: https://github.com/tryghost/docs/blob/main/install/source.mdx Enable pnpm using Corepack and then run the setup task. This command installs dependencies, initializes the database, sets up git hooks, and initializes submodules. ```bash # Only ever run this once corepack enable pnpm pnpm run setup ``` -------------------------------- ### Initialize and Run Gridsome Project Source: https://github.com/tryghost/docs/blob/main/jamstack/gridsome.mdx Commands to install the Gridsome CLI, create a new project from a starter template, and start the development server. ```bash npm install -g @gridsome/cli gridsome create gridsome-ghost https://github.com/gridsome/gridsome-starter-blog.git cd gridsome-ghost gridsome develop ``` -------------------------------- ### Start Development Server Source: https://github.com/tryghost/docs/blob/main/README.md Start the local development server for previewing documentation changes using the Mintlify CLI. ```bash mint dev ``` -------------------------------- ### Install Mintlify CLI Source: https://github.com/tryghost/docs/blob/main/CLAUDE.md Install the Mintlify CLI globally. This is a prerequisite for running other Mintlify commands. ```bash # Install Mintlify CLI globally (required) npm i -g mint ``` -------------------------------- ### Start Mintlify Development Server Source: https://github.com/tryghost/docs/blob/main/CLAUDE.md Start the development server to preview documentation changes locally. The default port is 3000. ```bash # Start development server (default port 3000) mint dev ``` -------------------------------- ### Ghost Configuration Options Source: https://github.com/tryghost/docs/blob/main/ghost-cli.mdx Examples of configuration flags for application, database, mail, and service settings that can be passed during installation or configuration. ```bash # Application --url https://mysite.com --port 2368 # Database --db mysql --dbhost localhost --dbuser ghost --dbname ghost_dev # Mail --mail SMTP --mailservice Mailgun # Service --process systemd ``` -------------------------------- ### Execute Ghost Installation Source: https://github.com/tryghost/docs/blob/main/install/ubuntu.mdx The primary command to trigger the Ghost-CLI installation process within the prepared directory. ```bash ghost install ``` -------------------------------- ### Update Package List and Install Node.js Source: https://github.com/tryghost/docs/blob/main/faq/node-versions.mdx After setting up the repository, this command updates your package list and installs the Node.js package. This ensures you get the version specified in the repository configuration. ```bash sudo apt-get update sudo apt-get install nodejs -y ``` -------------------------------- ### Ghost Maintenance and Troubleshooting Commands Source: https://github.com/tryghost/docs/blob/main/install/ubuntu.mdx Essential commands for managing an existing Ghost installation, including help, uninstallation, and setup recovery. ```bash # View available commands ghost help # Remove an installation ghost uninstall # Restart the configuration process ghost setup ``` -------------------------------- ### Prepare Ghost Installation Directory Source: https://github.com/tryghost/docs/blob/main/install/ubuntu.mdx Commands to create a dedicated directory for the Ghost installation, set appropriate ownership and permissions, and navigate into the folder. ```bash # Create directory: Change `sitename` to whatever you like sudo mkdir -p /var/www/sitename # Set directory owner: Replace with the name of your user sudo chown : /var/www/sitename # Set the correct permissions sudo chmod 775 /var/www/sitename # Then navigate into it cd /var/www/sitename ``` -------------------------------- ### Install Mintlify CLI Source: https://github.com/tryghost/docs/blob/main/README.md Install the Mintlify CLI globally to preview local documentation changes. Requires Node.js v20.17.0 or higher. ```bash npm i -g mint ``` -------------------------------- ### Initialize local Ghost installation Source: https://github.com/tryghost/docs/blob/main/install/local.mdx Runs the Ghost-CLI command to set up a local instance of Ghost in the current directory, configured for development mode. ```bash ghost install local ``` -------------------------------- ### Start Mintlify Development Server on Custom Port Source: https://github.com/tryghost/docs/blob/main/CLAUDE.md Start the development server on a custom port, such as 3333, if the default port is in use. ```bash # Start on custom port mint dev --port 3333 ``` -------------------------------- ### Start Ghost in Development Mode Source: https://github.com/tryghost/docs/blob/main/install/source.mdx Run Ghost in development mode. This command builds admin files on start and then watches for changes. ```bash # Run Ghost in development mode pnpm dev ``` -------------------------------- ### GET {{#get}} Helper Configuration Source: https://github.com/tryghost/docs/blob/main/themes/helpers/functional/get.mdx The {{#get}} helper allows theme developers to query Ghost resources like posts, tags, authors, and tiers with specific parameters. ```APIDOC ## GET {{#get}} Helper ### Description Fetch collections of data from the Ghost API within your theme templates. Supports pagination, ordering, relationship inclusion, and complex filtering. ### Parameters #### Query Parameters - **page** (integer) - Optional - The specific page of results to retrieve when the collection is paginated. - **limit** (integer) - Optional - The number of resources to return per request. - **order** (string) - Optional - Field name followed by 'asc' or 'desc' to define result sorting (e.g., 'published_at desc'). - **include** (string) - Optional - Comma-separated list of related data to fetch (e.g., 'authors,tags,count.posts'). - **filter** (string) - Optional - Logic-based query string to narrow results (e.g., 'featured:true'). ### Request Example {{#get "posts" limit="5" page="1" include="authors,tags" filter="featured:true" order="published_at desc"}}{{/get}} ### Response #### Success Response (200) - **data** (object) - The requested collection of resources (posts, tags, authors, etc.) based on the query parameters. #### Response Example {{#foreach posts}}

{{title}}

Written by: {{authors}}

{{/foreach}} ``` -------------------------------- ### Install Hexo CLI Source: https://github.com/tryghost/docs/blob/main/jamstack/hexo.mdx Installs the Hexo command-line interface globally using npm. This is a prerequisite for creating and managing Hexo sites. ```bash npm install -g hexo-cli ``` -------------------------------- ### Install Ghost-CLI globally Source: https://github.com/tryghost/docs/blob/main/install/local.mdx Installs the Ghost-CLI command-line tool globally using npm to enable Ghost management commands. ```bash npm install ghost-cli@latest -g ``` -------------------------------- ### Install dependencies for Ghost content export Source: https://github.com/tryghost/docs/blob/main/jamstack/vuepress.mdx Install the necessary Node.js packages to interact with the Ghost Content API, generate YAML frontmatter, and manage file system operations. ```bash yarn add @tryghost/content-api js-yaml fs-extra ``` -------------------------------- ### Check MySQL Version Source: https://github.com/tryghost/docs/blob/main/faq/supported-databases.mdx If your Ghost installation is configured to use MySQL, run `mysql --version` to check the specific version of your MySQL installation. ```bash mysql --version ``` -------------------------------- ### Validate Ghost themes with GScan Source: https://github.com/tryghost/docs/blob/main/install/local.mdx Installs the GScan utility globally and demonstrates how to validate theme directories or zip files for compatibility with Ghost. ```bash # Install gscan globally npm install gscan -g # Scan a theme directory for compatibility gscan /path/to/ghost/content/themes/casper # Scan a theme zip file for compatibility gscan -z /path/to/downloads/theme.zip ``` -------------------------------- ### Use posts_per_page Setting for Limit Source: https://github.com/tryghost/docs/blob/main/themes/helpers/functional/get.mdx Shows how to use the global `posts_per_page` setting, configured in `package.json`, to dynamically set the limit for the `{{#get}}` helper. ```handlebars {{#get "posts" limit=@config.posts_per_page}}{{/get}} ``` -------------------------------- ### Install Ghost Content API Helper Source: https://github.com/tryghost/docs/blob/main/jamstack/hexo.mdx Installs the official JavaScript Ghost Content API helper using Yarn. This library is used to fetch content from a Ghost CMS. ```bash yarn add @tryghost/content-api ``` -------------------------------- ### Install and Update Ghost-CLI Source: https://github.com/tryghost/docs/blob/main/ghost-cli.mdx Installs or updates the Ghost-CLI tool globally using npm. The @latest tag ensures the most recent version is retrieved. ```bash sudo npm install -g ghost-cli@latest ``` -------------------------------- ### Initialize Nuxt Application Source: https://github.com/tryghost/docs/blob/main/jamstack/nuxt.mdx Commands to scaffold a new Nuxt project and start the development server using the command line. ```bash yarn create nuxt-app my-nuxt-app cd my-nuxt-app yarn dev ``` -------------------------------- ### Fetch 15 Newest Posts with get Helper Source: https://github.com/tryghost/docs/blob/main/themes/helpers/functional/get.mdx Demonstrates fetching the 15 most recent posts using the `{{#get}}` helper and iterating through them with `{{#foreach}}`. This is a basic 'browse' query. ```handlebars {{#get "posts"}} {{#foreach posts}} {{title}} {{/foreach}} {{/get}} ``` -------------------------------- ### cURL Example: Create Session and Post Source: https://github.com/tryghost/docs/blob/main/admin-api.mdx Demonstrates creating a session using cURL, storing the cookie, and then using that cookie to create a post. Requires Origin and Accept-Version headers. ```bash # cURL # Create a session, and store the cookie in ghost-cookie.txt curl -c ghost-cookie.txt -d username=me@site.com -d password=secretpassword \ -H "Origin: https://myappsite.com" \ -H "Accept-Version: v3.0" \ https://demo.ghost.io/ghost/api/admin/session/ # Use the session cookie to create a post curl -b ghost-cookie.txt \ -d '{"posts": [{"title": "Hello World"}]}' \ -H "Content-Type: application/json" \ -H "Accept-Version: v3.0" \ -H "Origin: https://myappsite.com" \ https://demo.ghost.io/ghost/api/admin/posts/ ``` -------------------------------- ### Paginate Ghost 'get' Helper Results Source: https://github.com/tryghost/docs/blob/main/themes/helpers/functional/get.mdx Control which page of a collection is returned by the 'get' helper using the 'page' attribute. This is useful when the total number of items exceeds the requested limit, enabling pagination. ```handlebars {{! Get the 4th page of results. In this case, where limit = 5, we are accessing posts 16 - 20}} {{#get "posts" limit="5" page="4"}}{{/get}} ``` -------------------------------- ### Initialize a New Hexo Site Source: https://github.com/tryghost/docs/blob/main/jamstack/hexo.mdx Creates a new Hexo site in the specified directory. This command initializes the basic file structure for a Hexo project. ```bash hexo init my-hexo-site ``` -------------------------------- ### JSON Output Example Source: https://github.com/tryghost/docs/blob/main/themes/helpers/utility/json.mdx This is an example of the escaped JSON output produced by the `{{json}}` helper when used with site properties. ```json {"accent":"#FF1A75","title":"My site"} ``` -------------------------------- ### Configure Ghost Content API Client Source: https://github.com/tryghost/docs/blob/main/jamstack/nuxt.mdx Install the Ghost Content API library and initialize the API instance with site credentials to enable data fetching. ```bash yarn add @tryghost/content-api ``` ```javascript 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" }); ``` -------------------------------- ### Check Ghost Database Client Source: https://github.com/tryghost/docs/blob/main/faq/supported-databases.mdx Use the `ghost ls` command to find your Ghost installation and then `ghost config database.client` to determine if you are using `sqlite3` or `mysql`. ```bash ghost ls ghost config database.client ``` -------------------------------- ### Order Ghost 'get' Helper Results Source: https://github.com/tryghost/docs/blob/main/themes/helpers/functional/get.mdx Specify the sorting order for data retrieved by the 'get' helper using the 'order' attribute. You can sort by any valid resource field in ascending ('asc') or descending ('desc') order. ```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}} ``` -------------------------------- ### Webmention POST Request for Recommendations Source: https://github.com/tryghost/docs/blob/main/recommendations.mdx This example demonstrates a POST request sent to a recommended site's Webmention endpoint. It includes the source of the recommendation (the recommendations.json file) and the target site. ```http POST /webmentions/receive/ HTTP/1.1 Host: recommendedsite.com Content-Type: application/x-www-form-urlencoded source=https://mysite.com/.well-known/recommendations.json& target=https://recommendedsite.com/ ``` -------------------------------- ### Configure Ghost Logging Source: https://github.com/tryghost/docs/blob/main/config.mdx Set up logging parameters such as path, time format, level, rotation, and transports. Ensure the specified path has correct write permissions. ```json "logging": { "path": "something/", "useLocalTime": true, "level": "info", "rotation": { "enabled": true, "count": 15, "period": "1d" }, "transports": ["stdout", "file"] } ``` -------------------------------- ### Install gatsby-source-ghost Plugin Source: https://github.com/tryghost/docs/blob/main/jamstack/gatsby.mdx Installs the gatsby-source-ghost plugin for Gatsby projects. This is the initial step to integrate Ghost CMS content into your Gatsby site. ```bash npm install --save gatsby-source-ghost ``` -------------------------------- ### Include Related Data in Ghost 'get' Helper Source: https://github.com/tryghost/docs/blob/main/themes/helpers/functional/get.mdx Expand the data returned by the 'get' helper using the 'include' attribute. This allows fetching related resources like authors, tags, tiers, and their associated data, such as post counts or pricing information. ```handlebars {{! Get posts with author }} {{#get "posts" limit="5" include="authors"}} {{#foreach posts}} Written by: {{authors}} {{/foreach}} {{/get}} {{! Get posts with author and tags }} {{#get "posts" limit="5" include="authors,tags"}} {{#foreach posts}}

Written by: {{authors separator=", "}}

keywords: {{tags separator=", "}}

{{/foreach}} {{/get}} {{! 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}} {{! 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 yearly_price}}
Yearly – {{price yearly_price currency=currency}}
{{/if}} {{#if benefits}} {{#foreach benefits as |benefit|}} {{benefit}} {{/foreach}} {{/if}} {{/foreach}} {{/get}} {{! Create a dynamic sign-up form that allows members to subscribe to specific newsletters}}
{{#get "newsletters"}} {{#foreach newsletters}} {{else}} {{/get}}
``` -------------------------------- ### Filter Ghost 'get' Helper Results Source: https://github.com/tryghost/docs/blob/main/themes/helpers/functional/get.mdx Apply complex, logic-based queries to data fetched by the 'get' helper using the 'filter' attribute. This allows for precise selection of items based on boolean conditions, string matches, or group inclusions, with support for AND, OR, and negation. ```handlebars {{! Only get posts that are featured }} {{#get "posts" limit="25" filter="featured:true"}} {{#foreach posts}} {{title}} {{/foreach}} {{/get}} ``` -------------------------------- ### Fix Ghost Installation Errors Source: https://github.com/tryghost/docs/blob/main/install/source.mdx Run this command if you encounter 'Cannot find module' errors, often due to incomplete installations or Node.js version changes. ```bash pnpm fix ``` -------------------------------- ### Configure Server Host and Port Source: https://github.com/tryghost/docs/blob/main/config.mdx Set the IP address and port Ghost listens on. Nginx or Apache typically routes requests to this port. ```json "server": { "host": "127.0.0.1", "port": 2368 } ``` -------------------------------- ### Fetch All Authors and Iterate Source: https://github.com/tryghost/docs/blob/main/themes/helpers/functional/get.mdx Demonstrates fetching all authors using the `{{#get}}` helper and then iterating through the results using `{{#foreach}}`. This is a 'browse' query. ```handlebars {{#get "authors"}} {{! Loop through authors }} {{#foreach authors}} {{name}} {{/foreach}} {{/get}} ``` -------------------------------- ### Run Ghost in Production Mode Source: https://github.com/tryghost/docs/blob/main/config.mdx Use this command to start Ghost in production mode. This is the default for public publications. ```bash NODE_ENV=production node index.js ``` -------------------------------- ### Build Ghost from Source Source: https://github.com/tryghost/docs/blob/main/install/source.mdx Build a tarball archive of the Ghost project from the top-level directory of the monorepo. This archive can be installed using Ghost-CLI's --archive flag. ```bash pnpm archive ``` -------------------------------- ### Configure Environment Profiles Source: https://github.com/tryghost/docs/blob/main/install/docker.mdx Examples of how to update the COMPOSE_PROFILES variable in the .env file to enable analytics and ActivityPub features. ```bash COMPOSE_PROFILES=analytics,activitypub # Alternatively if you only want analytics COMPOSE_PROFILES=analytics # Alternatively if you only want activitypub COMPOSE_PROFILES=activitypub ``` -------------------------------- ### Example Recommendations JSON File Source: https://github.com/tryghost/docs/blob/main/recommendations.mdx This JSON file lists recommended sites, including their URLs and timestamps for creation and last update. It's automatically generated by Ghost and accessible at /.well-known/recommendations.json. ```json [ { "url": "https://shesabeast.co/", "updated_at": "2023-09-22T14:09:32.000Z", "created_at": "2023-09-22T14:09:32.000Z" }, { "url": "https://makerstations.io/", "updated_at": "2023-09-22T14:12:40.000Z", "created_at": "2023-09-22T14:12:34.000Z" } ] ``` -------------------------------- ### Create Next.js App Source: https://github.com/tryghost/docs/blob/main/jamstack/next.mdx This command initiates a new Next.js project. It prompts the user for project name and configuration options like TypeScript, ESLint, Tailwind CSS, and router preferences. The example shows opting out of most advanced features for simplicity. ```bash yarn create next-app ✔ What is your project named? … my-next-app ✔ Would you like to use TypeScript? … **No** / Yes ✔ Would you like to use ESLint? … **No** / Yes ✔ Would you like to use Tailwind CSS? … **No** / Yes ✔ Would you like your code inside a src/ directory? … **No** / Yes ✔ Would you like to use App Router? … **No** / Yes ✔ Would you like to use Turbopack for next dev? … **No** / Yes ✔ Would you like to customize the import alias? … **No** / Yes ``` -------------------------------- ### Manage MySQL Service and Configuration Source: https://github.com/tryghost/docs/blob/main/faq/troubleshooting-mysql-database.mdx Commands to start the MySQL service, verify connectivity, and locate the configuration file. These are essential for troubleshooting connection issues and applying SQL mode changes. ```bash sudo service mysql start mysql mysql --help sudo find / -name my.cnf ``` -------------------------------- ### Switch to New User and Verify Ghost Installation Source: https://github.com/tryghost/docs/blob/main/faq/root-user-fix.mdx After migrating the Ghost installation, this command switches the current user session to the newly created user. Subsequently, 'ghost ls' can be used to verify that the Ghost installation is still accessible and running correctly under the new user's privileges. ```bash su - ghost ls ``` -------------------------------- ### Clone Eleventy Starter Ghost Repository Source: https://github.com/tryghost/docs/blob/main/jamstack/eleventy.mdx This command clones the official Eleventy Starter for Ghost repository, providing a pre-configured boilerplate for building a static site with Ghost content. ```bash git clone git@github.com:TryGhost/eleventy-starter-ghost.git ``` -------------------------------- ### Fetch All Tags with Limit Source: https://github.com/tryghost/docs/blob/main/themes/helpers/functional/get.mdx Illustrates fetching up to 100 tags using the `{{#get}}` helper and then outputting them using the `{{tags}}` helper. This is a 'browse' query. ```handlebars {{#get "tags" limit="100"}}{{tags}}{{/get}} ``` -------------------------------- ### Debug Ghost Configuration Source: https://github.com/tryghost/docs/blob/main/config.mdx Start Ghost with the DEBUG environment variable to enable detailed logging for Ghost and its configuration modules. This is useful for troubleshooting. ```bash DEBUG=ghost:*,ghost-config node index.js ``` -------------------------------- ### Configure Default Storage Adapter Source: https://github.com/tryghost/docs/blob/main/config.mdx Use the `adapters` configuration block with the `storage` key to set a default storage module for Ghost. The `active` key specifies the module to use, followed by the module's configuration. ```json "adapters": { "storage": { "active": "storage-module-name", "storage-module-name": { "key": "value" } } } ``` -------------------------------- ### Install and Use GScan CLI Source: https://github.com/tryghost/docs/blob/main/themes.mdx Install the GScan npm package globally to use it as a command-line tool for theme validation. You can run GScan against a theme folder or a zip file. ```bash npm install -g gscan ``` ```bash gscan /path/to/ghost/content/themes/casper ``` ```bash gscan -z /path/to/download/theme.zip ```