【问题标题】:How to extract blog posts from Ghost and import in Github hosted jekyll?如何从 Ghost 中提取博客文章并导入 Github 托管的 jekyll?
【发布时间】:2015-01-07 08:31:36
【问题描述】:

Jekyll 网站已给出此说明,但并不完整。我从 ghost 博客下载了 ghost.db 并安装了 http://import.jekyllrb.com/docs/ghost/ 和 jekyll-import gem,它都是依赖项。并在上面的链接中运行给定的命令。它运行但它给出了错误

我也没有任何本地安装的 jekyll 网站。它托管在 github 上。

我想把我关于 ghost 的博客文章移到 github 托管的 jekyll 上。

我的操作系统是 OSX Yosemite。

【问题讨论】:

  • 您是否安装了所有正确的 gem?我从未亲自进行过导入,但它看起来像是缺少 gem 错误。
  • @JitendraVyas 您是如何获得ghost.db 文件的?我的意思是,你是从content/data 复制的还是使用导出按钮下载的?
  • @TamerShlash 我从 DigitalOcean 的 ghost 安装中下载
  • @JitendraVyas 您是在content/data 之类的地方找到它还是刚刚登录到您的Ghost 安装并点击“导出”按钮?
  • @JitendraVyas 使用sqlitebrowser.org 检查并验证ghost.db 文件的格式是否有效,并且它确实包含posts 表;这可以提供有关导入脚本失败原因的更多信息。

标签: ruby sqlite jekyll ghost-blog


【解决方案1】:

你必须从 ghost.db 所在的文件夹运行你的命令。

如果你没有从 db 文件夹中启动你的命令,你可以给出一个绝对路径,比如

"dbfile"   => "/home/user/ghost.db"

或者数据库名称不是一个好名称。也许是ghost-dev.dbghost-prod.db

【讨论】:

  • 赏金消失了。太糟糕了。
【解决方案2】:

另一种选择是将您的 ghost 博客导出为 json,然后将该 json 文件转换为 Jekyll GitHub 页面的 markdown 文件。

json 文件很容易解释,因此您可以编写一个简单的程序来解析文件并从中创建 markdown 文件。

流程如下所示:

  • 将 json 文件读入内存。
  • 解析来自db.data.posts的帖子。
  • 对于每个帖子:
    • markdown 内容在post markdown 属性中。
    • 从其他 post 属性创建您的前端。
    • 编写一个带有前文和原始降价的文件,将带有日期的文件名添加到输出文件夹中的_posts 文件夹中。
    • 注意:如果page 属性为0,则为帖子,如果为1,则为页面。如果是页面,则该文件应位于输出文件夹的根目录中,文件名中不包含日期。

每个帖子文件应如下所示:

---
layout: post
title: Welcome to Ghost
permalink: /welcome-to-ghost
date: 2017-04-25 20:54:20
published: false
tags: 
---

You're live! Nice. We've put together a little post to introduce you to the Ghost editor and get you started. You can manage your content by signing in to the admin area at `<your blog URL>/ghost/`. When you arrive, you can select this post from a list on the left and see a preview of it on the right. Click the little pencil icon at the top of the preview to edit this post and read the next section!

如果您正在寻找现有实用程序或示例代码,请尝试GhostToGitHubPagesConverter。这是一个 dotnet 核心控制台应用程序,可以在 windows、mac 或 linux 上运行。

完全公开,这是我的 github 项目。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-26
    • 2022-12-25
    • 2020-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多