ruby - 在 jekyll 中导入 wordpress 帖子

标签 ruby wordpress jekyll blogs

我已经有一个由 wordpress 维护的博客。现在,我打算将我的博客文章移动到 jekyll。

我已经从 jekyllnow 中 fork 了 jekyll 基本博客模板

然后我尝试使用 Wordpress to jekyll exporter 将我所有的博客文章从 wordpress 导入到 jekyll插件如本 smashing magazine article 中所述.

To export from WordPress, I’d highly recommend Ben Balter’s one-click WordPress to Jekyll Exporter plugin.

这对我不起作用。

因此,我的第二次尝试是将 wordpress 帖子导出到 xml 文件中,如同一篇热门杂志文章中所述。

The other option is to export all content in the “Tools” menu of the WordPress dashboard, and then importing it with Jekyll’s importer.

所以,我首先只将我的帖子从 wordpress 导出到 xml。

Wordpress Admin -> Tools -> Export -> checked posts -> Download xml file

并将该 xml 文件放在我的项目文件夹中,该文件夹的目录名称为 kamlekar.github.io

然后在 Ruby 的命令提示符下,我 cd 到我的项目文件夹并运行以下代码,如下图所示:

enter image description here

如您所见,我收到以下错误:

-e:1: syntax error, unexpected '=', expecting tASSOC

我写的命令是

ruby -rubygems -e 'require "jekyll-import"; JekyllImport::Importers::WordpressDotCom.run({ "source" => "wpexport.xml"} )

我不确定为什么会出现此错误。我已经安装了 gem install github-pagesgem install jekyll-import

这是一个dummy xml file重现问题。


我在安装了 Ruby 1.9.2 的 Windows 8 上。

最佳答案

我在 irb(Interactive Ruby)中运行了相同的代码

$ irb

它给了我一些详细的错误,我需要安装 hpricot。所以,我安装了 hpricot。

irb > exit
$ cd <project_folder>
$ gem install hpricot

但 ruby​​ 命令提示符仍然给我错误。因此,我通过 irb 运行导入程序代码。作为explained by Wayne

$ irb
irb>  require "jekyll-import"; JekyllImport::Importers::WordpressDotCom.run({ "source" => "wpexport.xml"} )

成功了!!

但在我导入的帖子中,页面左上角仍然有 }); 之类的字符。我通过访问 _posts/ 中的每个帖子文件删除了它,并从帖子的元内容中删除了 options:{} 行。

感谢JonathanWayne因为在 Ruby chatroom 中有支持.

关于ruby - 在 jekyll 中导入 wordpress 帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31216857/

相关文章:

wordpress - jPlayer 2.6.0无法播放音频,找不到支持的源错误

ruby - 如何阻止 Guard 创建占用大量空间的日志文件

ruby - 需要且无法加载此类文件

ruby - 不运行 mongodb 的 mongoid 单元测试

用于 Twitter 用户/站点流的 Ruby 库?

javascript - 对页面加载的奇怪影响

html - 找不到风格的来源

html - jekyll怎么判断是page还是post呢?

macos - 安装ffi(1.9.21)时发生错误,并且Bundler无法继续。捆绑之前,请确保 `gem install ffi -v ' 1.9.2 1'`成功

ruby - 运行 Jekyll 时出错 – 库未加载 :/usr/local/opt/ruby/lib/libruby. 3.0.dylib (LoadError)