A note from the authors: Some of the information and instructions in this book are now out of date because of changes to Hugo and the blogdown package. If you have suggestions for improving this book, please file an issue in our GitHub repository. Thanks for your patience while we work to update the book, and please stay tuned for the revised version!

In the meantime, you can find an introduction to the changes and new features in the v1.0 release blog post and this "Up & running with blogdown in 2021" blog post.

— Yihui, Amber, & Alison

1.8 A recommended workflow

有很多方法可以开始构建网站并部署它。由于要完全理解网站的工作原理,您需要学习大量的技术,因此我们想向初学者推荐一种工作流程,以便他们不需要消化本书的其余部分。这绝对不是最优化的工作流程,但需要您了解最少的技术细节。

要启动一个新网站:

  1. https://themes.gohugo.io 上仔细选择一个主题,并找到其 GitHub 存储库的链接,其格式为 https://github.com/user/repo

  2. 在 RStudio 中创建一个新项目,然后在 R 控制台中键入代码 blogdown::new_site(theme = 'user/repo'),其中 user/repo 来自步骤 1 中的链接。

  3. 使用新站点一段时间,如果您不喜欢它,可以重复上述步骤,否则编辑 config.toml 中的选项。如果您不理解某些选项,请转到主题的文档,这通常是 GitHub 存储库的 README 页面。并非所有选项都必须更改。

编辑网站:

  1. 单击 RStudio 插件 “Serve Site” 以在 RStudio Viewer 中预览站点。只需在每次打开 RStudio 项目或重新启动 R 会话时执行一次此操作。不要单击 RStudio 工具栏上的 Knit 按钮。

  2. 使用 “New Post” 插件创建新帖子或页面,然后开始编写内容。

  3. 如有必要,请使用 “Update Metadata” 插件修改 YAML metadata。

要发布网站,请参阅 Section 1.3