考虑从 WordPress 迁移到 Jekyll:什么去了哪里?

发布于 2024-11-26 18:27:32 字数 301 浏览 3 评论 0原文

我正在尝试弄清楚将我当前的博客从 WordPress 迁移到 Jekyll 需要什么,因为目前 MySQL 对于我的口味来说确实太复杂了。我已经阅读了 GitHub 上有关配置、使用等的文档,但安装不太清楚。

我假设既然帖子、布局和其他文件都保存在本地,那么所需的 Ruby gems 也是如此?同时,我看到其他人谈论安装到网络主机(在我的例子中是 Dreamhost),这将是理想的,但我仍然不确定。

另外,我使用 Mercurial 而不是 Git 来进行 SCM,所以我可能需要确保我可以使用 Hg-Git 之类的东西来帮助部署。任何帮助将不胜感激!

I'm trying to figure out what would be required to move my current blog from WordPress to Jekyll, as MySQL is really too complex for my taste at this point. I've read the docs on GitHub about Configuration, Usage etc, but Installation is less clear.

I assume that since posts, layouts and other files are kept locally, that the required Ruby gems are as well? At the same time, I've seen others talk about installing to a web host (Dreamhost in my case), which would be ideal, but I'm still not sure.

Also, I'm using Mercurial instead of Git for SCM, so I would probably need to make sure I can use something like Hg-Git to help deploy things. Any help would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

流绪微梦 2024-12-03 18:27:32

我认为你的问题可以从两个角度来回答:1)如何启动并运行 Jekyll;2)如何将当前的 Wordpress 内容导入 jekyll。以下是帮助您依次开始了解每个问题的答案。

第 1 部分 - 让 Jekyll 启动并运行

首先要认识到的是,Jekyll 旨在生成一组静态 HTML 文件,这些文件基本上可以从任何 Web 服务器提供,而不需要 PHP、Ruby、Perl 或任何其他动态服务器端加工。

当然,Jekyll 使用 Ruby,因此无论您在哪里生成文件,都必须运行它。虽然这可能位于提供文件的同一服务器上,但重要的是它不一定是这样。例如,所有这些都是使用 Jekyll 发布的有效工作流程:

  1. 在您的个人计算机上创建原始文件,在那里运行 Jekyll 生成静态 HTML 文件,然后将它们传输到您的远程 Web 服务器以供全世界查看。< /p>

  2. 直接在服务器上运行 Jekyll,对原始文件进行所有编辑和创建,让 Jekyll 处理它们,以便由该计算机上的 Web 服务器软件提供服务。

  3. 在服务器计算机上运行 Jekyll,但在本地计算机上编辑原始文件,并在准备发布时将它们推送到服务器。 Jekyll 引擎将获取原始文件并在服务器本身上生成静态 HTML 文件。

人们还拥有更复杂的设置,允许他们从笔记本电脑、手机和服务器本身发布内容,并通过 Dropbox 全面同步所有内容。你可以随心所欲地发挥创意,但我认为最简单的开始就是第一个。在本地编辑原始文件,在本地运行 Jekyll,然后在准备好上线时将生成的 HTML 文件传输到您的 Web 服务器。

本地安装 Jekyll

显然,您需要在本地计算机上安装 Jekyll。可以在Github 页面找到相关说明。对于我自己来说,运行 Mac OS X 10.6,以下命令让我进行设置。

sudo gem install rubygems-update
sudo update_rubygems

sudo gem update
sudo gem update --system

sudo gem install rails

sudo gem install maruku

sudo gem install jekyll

注意:我认为您实际上并不需要 Rails,但这些是我经历过的步骤,并且它们对我有用

设置使用 Jekyll

一旦您的计算机上安装了 Jekyll,就可以进行基本的站点设置比较简单。在空目录中创建以下结构:

目录:

  • _layouts
  • _posts
  • _site

文件及其内容:

  • _config.yml

    安全:假
    自动:假
    服务器:假
    服务器端口:4000
    基本网址:/
    
    来源: 。
    目的地:./_site
    插件:./_plugins
    
    未来:真实
    大规模集成电路:假
    图像:假
    降价:maruku
    永久链接: 日期
    
    丸久:
      use_tex:假
      use_div:假
      png_engine: blahtex
      png_dir: 图像/乳胶
      png_url:/图像/乳胶
    
    折扣:
      扩展名:[]
    
    克拉姆当:
      自动ID:真,
      脚注编号:1
      实体输出:as_char
      目录级别:1..6
      use_coderay:假
    
      码锐:
        coderay_wrap:div
        coderay_line_numbers:内联
        coderay_line_numbers_start: 1
        coderay_tab_width: 4
        coderay_bold_every:10
        coderay_css:样式
    

    这是 Jekyll 的默认配置设置。您可以在没有此文件的情况下逃脱,但当进程运行时它会发出找不到该文件的警告。所以,我会继续进行设置。它还使得处理东西变得更加容易,而不是在命令行上向 jekyll 发送参数。

  • _layouts/default.html

    
    
    <头>
        <元字符集=“utf-8”>
        <标题>我的杰基尔网站
    
    <正文>
    
        
        {{ 内容 }}
    
        {{ 网站.帖子 }}
    
    
    
    

    {{ content }} 字符串将替换为下面列出的“index.md”文件的已处理内容。 {{ site.posts }} 字符串将替换为“_posts”目录中按时间顺序排列的文件列表。 GitHub 有一个模板代码片段的完整列表

  • _posts/2011-07-29-my-first-jekyll-post.md

    <前><代码>---
    布局:默认
    ---

    # 我的第一篇 Jekyll 帖子。

    这是2011-07-29-my-first-jekyll-post.md的内容

  • index.md

    <前><代码>---
    布局:默认
    ---

    # 我的 Jekyll 网站

    这是index.md的内容

这里值得指出的是,您可以使用 .html 或 .textile 文件而不是 .md 版本。只要有 YAML Front Matter,即由破折号和“layout:default”组成的前三行,它们就会被 Jekyll 处理。

使用 Jekyll 生成静态文件

现在您的起始文件和目录结构已设置完毕,只需打开命令提示符,转到创建 index.md 文件的目录并运行命令 jekyll 即可。假设一切顺利,您应该会看到该过程的简短日志,并且现在下面有两个 HTML 文件:

_site/index.html
and
_site/2011/07/29/my-first-jekyll-post.html

值得指出的是原始文件源的 Markdown (.md) 文件。您也可以使用 .textile 或 .html。

传输/部署文件。

这种方法的最后一步就是使用 FTP 或 rsync 将文件推送到 Web 服务器的根目录并与世界共享。由于它们是平面 HTML,因此可以快速轻松地为它们准备好几乎任何托管服务。

(在您的问题中,您提到了 Git 和 Mercurial。您可以使用它们进行版本控制和/或部署原始文件以及 Jekyll 生成的静态 HTML 文件,但 Jekyll 不需要运行或传输您的文件。这完全取决于您希望如何设置部署过程。)

第 2 部分 - 从 WordPress 迁移数据

上面的所有内容都是关于从头开始有效地使用 Jekyll 本身。如果您一直在使用 WordPress(或任何其他引擎)并希望保留在那里生成的页面和帖子,则需要将它们从 WordPress 迁移到 Jekyll。

基本思想是,您将帖子和页面移动到 Jekyll 目录中的相应位置,并让它从那里接管。我将在 Jekyll 博客迁移页面 上开始对该主题的研究。

就我个人而言,我第一次尝试 WordPress 迁移并没有开箱即用。我还没有机会重新开始它,但我致力于实现它迁移到一个更简单的静态站点可以减少潜在的安全问题,加载速度更快并且更容易维护,这对我来说完全值得进行迁移。

I think your question can be answered from two standpoints: 1) How to get Jekyll up and running and 2) How to get your current Wordpress content into jekyll. Here's answers to get you started with each in turn.

Part 1 - Getting Jekyll Up and Running

The first thing to realize is that Jekyll is designed to generate a set of static HTML files that can be served from basically any web server without the need for PHP, Ruby, Perl or any other dynamic server side processing.

Of course, Jekyll uses Ruby, so you have to have that running wherever you do the file generation. While that could be on the same server that serves the file the important point is that it doesn't have to be. For example, all of these are valid workflows for posting with Jekyll:

  1. Create raw files on your personal machine, run Jekyll there to generate the static HTML files and then transfer them to your remote web server for the world to see.

  2. Run Jekyll directly on your server doing all editing and creation of raw files there to have Jekyll process them for serving by the web server software on that machine.

  3. Run Jekyll on your server machine, but edit the raw files on your local machine and push them to the server when you are ready to post. The Jekyll engine will take the raw files and do the static HTML file generation on the server itself.

People also have much more complex setups that allow them to post from either their laptops, their phones and the server itself and get everything synced up across the board via Dropbox. You can get as creative as you want with that, but I think the simplest one to get started with is the first one. Edit your raw files locally, run Jekyll locally and then transfer the resulting HTML files to your web server when you're ready for them to go live.

Installing Jekyll Locally

Obviously, you'll need Jekyll installed on your local machine for this. Directions for that can be found on the Github page. For myself, running Mac OS X 10.6, the following commands got me setup.

sudo gem install rubygems-update
sudo update_rubygems

sudo gem update
sudo gem update --system

sudo gem install rails

sudo gem install maruku

sudo gem install jekyll

Note: I don't think you actually need rails, but those are the steps I went through and they worked for me

Setting Up To Use Jekyll

Once you have Jekyll on your machine, getting a basic site setup is relatively simple. Create the following structure in an empty directory:

Directories:

  • _layouts
  • _posts
  • _site

Files and their content:

  • _config.yml

    safe:        false
    auto:        false
    server:      false
    server_port: 4000
    base-url:    /
    
    source:      .
    destination: ./_site
    plugins:     ./_plugins
    
    future:      true
    lsi:         false
    pygments:    false
    markdown:    maruku
    permalink:   date
    
    maruku:
      use_tex:    false
      use_divs:   false
      png_engine: blahtex
      png_dir:    images/latex
      png_url:    /images/latex
    
    rdiscount:
      extensions: []
    
    kramdown:
      auto_ids: true,
      footnote_nr: 1
      entity_output: as_char
      toc_levels: 1..6
      use_coderay: false
    
      coderay:
        coderay_wrap: div
        coderay_line_numbers: inline
        coderay_line_numbers_start: 1
        coderay_tab_width: 4
        coderay_bold_every: 10
        coderay_css: style
    

    This is the default configuration setup for Jekyll. You can get away without this file, but it throws a warning when the process runs that it can't find the file. So, I'd go ahead and set it up. It also makes it much easier to mess around with stuff instead of sending arguments to jekyll on the command line.

  • _layouts/default.html

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html lang="en">
    <head>
        <meta charset="utf-8">
        <title>My Jekyll Site</title>
    </head>
    <body>
    
        <!-- This will be replaced with your content -->
        {{ content }}
    
        {{ site.posts }}
    
    </body>
    </html>
    

    The {{ content }} string will be replaced by the processed content of the "index.md" file listed below. The {{ site.posts }} string will be replaced by a reverse chronological listing of the files in the "_posts" directory. GitHub has a full list of the template code snippets.

  • _posts/2011-07-29-my-first-jekyll-post.md

    ---
    layout: default
    ---
    
    # My first Jekyll post.
    
    This is the content from 2011-07-29-my-first-jekyll-post.md
    
  • index.md

    ---
    layout: default
    ---
    
    # My Jekyll site
    
    This is the content from index.md
    

It's worth pointing out here that you could use .html or .textile files instead of .md versions. As long as the had the YAML Front Matter, which is the first three lines consisting of the dashes and "layout: default", they will be processed by Jekyll.

Generating Static Files With Jekyll

Now that your starting file and directory structure is setup, simply bring up your command prompt, go to the directory where you create the index.md file and run the command jekyll. Assuming everything went well, you should see a short log of the process and you'll have two HTML files now sitting under:

_site/index.html
and
_site/2011/07/29/my-first-jekyll-post.html

It's worth pointing out Markdown (.md) files for the raw file source. You can also use .textile or .html as well.

Transferring/Deploying Files.

The last step with this approach is simply to use FTP or rsync to push the files up to the root of your web server and share them with the world. Since they are flat HTML, it should be quick and painless getting pretty much any hosting provide ready to go for them.

(In your question you mention Git and Mercurial. You can use either to do version control and/or deploy your raw files as well as the static HTML files the Jekyll generates, but neither is required for Jekyll to run or to transfer your files. It's all about how you want to setup the deployment process.)

Part 2 - Migrating Data From WordPress

Everything above has been about using Jekyll itself starting effectively from scratch. If you have been using WordPress (or any other engine for that matter) and want to keep the pages and posts you generated there, you'll need to migrate them from WordPress to Jekyll.

The basic idea is that you would move your posts and pages into corresponding locations inside the Jekyll directory and let it take over from there. I would start your research on that topic on the Jekyll Blog Migrations page.

(On a personal note, my first attempt at a WordPress migration didn't work out of the box. I haven't had a chance to jump back into it to get it going, but I'm committed to making it work. Moving to a much simpler static site that reduces the potential security issues, loads faster and is easier to maintain is totally worth having to deal with a migration for me.)

吃素的狼 2024-12-03 18:27:32

安装jekyll后,你可以尝试这个wordpress插件 https://github.com/benbalter/ WordPress 到 Jekyll 导出器

After you installed jekyll, you can try this wordpress plugin https://github.com/benbalter/wordpress-to-jekyll-exporter

混吃等死 2024-12-03 18:27:32

据我了解,Jekyll 生成静态 HTML 网站。当然,Jekyll 包含一些 Ruby 软件,但您可以在任何计算机上运行这些软件(例如您的家庭计算机而不是 Web 服务器)。这样,您的网络托管需求就可以通过简单的静态系统(例如 Github Pages)来满足。现在,Github 可以自动为您处理 Jekyll 调用,但一般来说,想法是将静态 HTML 上传到哑 Web 服务器。

我认为没有必要将 Git 专门用于 Jekyll 创建的站点 — 我确信甚至 FTP 也可以。

As I understand it, Jekyll produces static HTML sites. Of course Jekyll consists of some Ruby software, but that's something you can run on any computer (e.g. your home computer rather than the web server). This way, your web hosting needs can be satisfied by simple static systems such as Github Pages. Now, Github can handle the Jekyll invocation for you automatically, but in general the idea is to upload static HTML to dumb web servers.

I don't think there's any need to use Git specifically with Jekyll-created sites—I'm sure even FTP would be fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文