Skip to content

从 Jekyll 迁移

Jekyll 是一个基于 Ruby 构建的静态站点生成器。

¥Jekyll is a static site generator built on Ruby.

Jekyll 和 Astro 之间的主要相似之处

Section titled Jekyll 和 Astro 之间的主要相似之处

¥Key Similarities between Jekyll and Astro

Jekyll 和 Astro 有一些相似之处,可以帮助你迁移项目:

¥Jekyll and Astro share some similarities that will help you migrate your project:

  • Jekyll 和 Astro 都是静态站点生成器,通常用于创建博客。

  • Jekyll 和 Astro 都允许你使用 Markdown 和 HTML 编写内容。Jekyll 和 Astro 都为页面布局和未发布的草稿帖子提供了一些特殊的 frontmatter YAML 属性。你可以继续在 Astro 中使用现有的 Markdown 文件。

  • Jekyll 和 Astro 都使用 基于文件的路由 从你的博客文章创建页面。Astro 提供了 所有页面和帖子的特殊 src/pages/ 目录。Jekyll 使用一个名为 _posts/ 的类似特殊文件夹来存放你的 Markdown 博客文章,但是你的网站页面可以存在于其他地方。创建新的博客文章应该感觉很熟悉。

Jekyll 和 Astro 之间的主要区别

Section titled Jekyll 和 Astro 之间的主要区别

¥Key Differences between Jekyll and Astro

当你在 Astro 中重建 Jekyll 站点时,你会注意到一些重要的差异:

¥When you rebuild your Jekyll site in Astro, you will notice some important differences:

  • 由于 Jekyll 主要是一个博客平台,因此你可能需要在 Astro 中自行构建一些内置博客功能。或者,选择包含这些功能的 博客入门模板主题。例如,Jekyll 内置了对标签和类别的支持,你可以在多个 Astro 博客主题中找到这些支持,但不包含在最小的 Astro 项目中。

  • Jekyll 使用 Liquid 模板来实现可重用的布局元素和模板。Astro 使用类似 JSX 的 .astro files for templating and components. Any .astro file can be a component, a layout or an entire page, and can import and render any other Astro components. You can also build using other UI framework components (e.g. React, Svelte, Vue, Solid) 以及来自 项目中的其他文件 的内容或元数据,例如 Markdown 或 MDX。

¥Switch from Jekyll to Astro

要将 Jekyll 博客转换为 Astro,请从我们的博客主题入门模板开始,或者在我们的 主题展示 中探索更多社区博客主题。

¥To convert a Jekyll blog to Astro, start with our blog theme starter template, or explore more community blog themes in our theme showcase.

你可以将 --template 参数传递给 create astro 命令,以使用我们的官方启动器之一启动一个新的 Astro 项目。或者,你可以 从 GitHub 上任何现有的 Astro 存储库启动一个新项目

¥You can pass a --template argument to the create astro command to start a new Astro project with one of our official starters. Or, you can start a new project from any existing Astro repository on GitHub.

Terminal window
npm create astro@latest -- --template blog

使用 Astro Markdown 布局 而不是 Liquid 模板,将现有 Markdown 文件作为内容引入 创建 Markdown 页面

¥Bring your existing Markdown files as content to create Markdown pages, using an Astro Markdown layout instead of a Liquid template.

你现有的大部分 HTML 页面内容都可以转换为 Astro pages, and you will additionally be able to use variables, JSX-like expressions and component imports directly in your HTML templating

¥Much of your existing HTML page content can be converted into Astro pages, and you will additionally be able to use variables, JSX-like expressions and component imports directly in your HTML templating.

Astro 没有接受占位符的 permalink 属性。如果你想保留现有的 URL 结构,你可能需要阅读有关 Astro 的页面路由 的更多信息。或者,考虑 在 Netlify 等主机上设置重定向

¥Astro does not have a permalink property that accepts placeholders. You may need to read more about Astro’s page routing if you want to keep your existing URL structure. Or, consider setting redirects at a host like Netlify.

要转换其他类型的网站,例如作品集或文档网站,请参阅 astro.new 上的更多官方入门模板。你将找到每个项目的 GitHub 存储库的链接,以及用于在 StackBlitz、CodeSandbox 和 Gitpod 在线开发环境中打开工作项目的一键链接。

¥To convert other types of sites, such as a portfolio or documentation site, see more official starter templates on astro.new. You’ll find a link to each project’s GitHub repository, as well as one-click links to open a working project in StackBlitz, CodeSandbox and Gitpod online development environments.

¥Community Resources

More migration guides

Astro 中文网 - 粤ICP备13048890号