Tenten Accelerator
  • 文章
  • Tech Blog
  • AI 實驗室
  • About
    • FAQ
    • FAQ (中文)
  • Service
    • Webflow 線上課程
    • D2C 品牌服務
    • 無頭電商 Headless
    • Internship 實習
  • Resources
    • Webflow FB 社團
    • 學習資源
    • tenten 設計小學堂 – Youtube
No Result
View All Result
Tenten | Digital Product Studio
  • 文章
  • Tech Blog
  • AI 實驗室
  • About
    • FAQ
    • FAQ (中文)
  • Service
    • Webflow 線上課程
    • D2C 品牌服務
    • 無頭電商 Headless
    • Internship 實習
  • Resources
    • Webflow FB 社團
    • 學習資源
    • tenten 設計小學堂 – Youtube
No Result
View All Result
Tenten | Digital Product Studio
No Result
View All Result

How to run Ghost CMS on Vercel

by Aiko
September 9, 2023
in AWS, Development, Headless
0
How to run Ghost CMS on Vercel

Hosting Ghost CMS directly on Vercel is challenging because Ghost requires a backend server (it’s built on Node.js), while Vercel is designed primarily for frontend applications, static websites, and serverless functions. However, a common approach is to use Ghost as a headless CMS and fetch content via its API, then display this content using a framework like Next.js, which can be hosted on Vercel.

Here’s a detailed step-by-step tutorial to set up Ghost CMS as a headless CMS with a Next.js frontend hosted on Vercel:

Step 1: Setting Up Ghost CMS

  1. Host Ghost on a server like DigitalOcean, or use a managed platform like Ghost(Pro). After setting it up, make note of your Content API URL and key.

Step 2: Setting Up Your Next.js Application

  1. Create a new Next.js application:

    npx create-next-app ghost-next-vercel
    cd ghost-next-vercel
    
  2. Install the Ghost Content API package:

    npm install @tryghost/content-api
    
  3. Set up the Ghost API in your Next.js application. In the root of your project, create a new file named ghost.js. This will be your Ghost client.

    const GhostContentAPI = require('@tryghost/content-api');
    
    const api = new GhostContentAPI({
      url: 'YOUR_GHOST_API_URL',
      key: 'YOUR_GHOST_CONTENT_API_KEY',
      version: 'v4',
    });
    
    export default api;
    

    Replace 'YOUR_GHOST_API_URL' and 'YOUR_GHOST_CONTENT_API_KEY' with your Ghost installation’s details.

  4. Now, you can fetch and display content from Ghost in your Next.js pages. As an example, create a simple page to display all posts:

    In pages/posts.js:

    import api from '../ghost';
    
    export async function getStaticProps() {
      const posts = await api.posts.browse();
    
      return {
        props: { posts }
      };
    }
    
    function Posts({ posts }) {
      return (
        <div>
          {posts.map(post => (
            <div key={post.id}>
              <h2>{post.title}</h2>
              <div dangerouslySetInnerHTML={{ __html: post.html }} />
            </div>
          ))}
        </div>
      );
    }
    
    export default Posts;
    

Step 3: Hosting on Vercel via GitHub

  1. Push your Next.js project to a GitHub repository.

  2. Sign up or log in to Vercel and link your GitHub account.

  3. Import the repository into Vercel. Vercel will automatically detect it’s a Next.js project and set up build configurations.

  4. Deploy your project. Every push to the main branch of your GitHub repository will trigger a deploy on Vercel.

Now, your Next.js frontend is set up to fetch content from Ghost CMS and is hosted on Vercel. Make sure to regularly rebuild your Vercel project to reflect changes made in your Ghost CMS. You can use Vercel’s webhook system combined with Ghost’s webhook feature to automate this process.

Related Posts

Revolutionizing Retail: 10 Trailblazers in Headless Shopify E-Commerce
Development

Revolutionizing Retail: 10 Trailblazers in Headless Shopify E-Commerce

Headless Shopify stores are not just a fleeting trend; they represent a technological revolution in the e-commerce landscape. This...

by Aiko
November 30, 2023
Exploring Shopify Front End Architectural Choices at Tenten
Development

Exploring Shopify Front End Architectural Choices at Tenten

At Tenten, our mission is to craft unique eCommerce experiences for brands and retailers using Shopify. Over time, we've...

by Aiko
November 29, 2023
Configuring Cloudflare Load Balancing for WordPress (Woocommerce)
Development

Configuring Cloudflare Load Balancing for WordPress (Woocommerce)

In this guide, we will demonstrate how to set up a Cloudflare DNS load balancer for Wordpress

by Aiko
November 29, 2023
How to make Woocommerce Headless on Vercel
Development

How to make Woocommerce Headless on Vercel

To make WooCommerce headless on Vercel, you need to separate the front end and back end of your WooCommerce...

by Aiko
November 29, 2023
Tenten | Digital Product Studio




Pioneering customer experiences through data-driven insights. We build engaging user experiences for startups and corporates by connecting the dots between users’ needs and the client’s business model.

通過數據驅動的洞察力開拓客戶體驗。我們將用戶需求與客戶的商業模式聯繫起來,為新創企業和公司打造引人入勝的用戶體驗 - Tenten=產品孵化器。





Follow us

© 2023 Tenten - Premium Webflow Agency. Shopify Plus + Low Code Agency in Asia

No Result
View All Result
  • 文章
  • Tech Blog
  • AI 實驗室
  • About
    • FAQ
    • FAQ (中文)
  • Service
    • Webflow 線上課程
    • D2C 品牌服務
    • 無頭電商 Headless
    • Internship 實習
  • Resources
    • Webflow FB 社團
    • 學習資源
    • tenten 設計小學堂 – Youtube

© 2023 Tenten - Premium Webflow Agency. Shopify Plus + Low Code Agency in Asia