呈现 Hugo/blogdown 站点时出现问题
Problem with rendering Hugo/blogdown site
我看过关于 blogdown::serve_site()
no longer serving the site 的 post 并阅读了 blogdown 0.21 的发行说明,但这对我的问题没有帮助。
我的工作流程is/was写一个post,然后在RStudio中点击“Serve Site”,在我项目的public/文件夹中查看新生成的文件。我的 ShinyApps 目录中有一个该文件夹的符号 link,因此我可以通过 Shiny 服务器查看我的站点。这太棒了,因为这样我也使用该服务器的同事也可以看到我的站点。
现在这不再起作用了。当我直接在 RStudio 中获取更新后的站点时,Shiny 服务器显示的文件没有更新。我能找到的唯一解释是:
The global option blogdown.generator.server has been deprecated. Now blogdown::serve_site() always use the Hugo server (which corresponds to options(blogdown.generator.server = TRUE) in previous version of blogdown), instead of the server created via the servr package (which corresponds to the default options(blogdown.generator.server = FALSE) before).
我不太了解 Hugo,但我发现 hugo server
不会更新 public/ 目录,对吗?我现在可以做什么来更新它?
问题已经 answered on GitHub:
我需要使用 blogdown::build_site(local=TRUE)
.
构建网站
编辑: 事实证明,以下对我来说也不是解决方案。因此,我 post 提出了一个可能的解决方法的问题:
Problem (and solution?) with rendering Hugo/blogdown site
较早(旧)post:
这对我没有帮助。更新 blogdown 并启动我的 R 项目时,blogdown:::preview_site(startup = TRUE)
会自动运行。我不记得早期初创企业的事情。我现在总是收到相同的错误消息:
Launching the server via the command:
hugo server --bind 127.0.0.1 -p 4321 --themesDir themes -t hugo-academic -D -F --navigateToChanged
sh: line 0: kill: (3262) - No such process
Error: It took more than 30 seconds to launch the server. There may be something wrong. The process has been killed. If the site needs more time to be built and launched, set options(blogdown.server.timeout) to a larger value.
运行 blogdown::build_site(local = TRUE)
导致更长的错误消息,开头为:
ERROR 2020/11/13 15:55:56 render of "page" failed: execute of template failed: template: _default/single.html:6:5: executing "_default/single.html" at <partial "page_header.html" .>: error calling partial: execute of template failed: template: partials/page_header.html:92:7: executing "partials/page_header.html" at <partial "page_metadata" (dict "page" $page "is_list" 0 "share" true)>: error calling partial: "/Users/frederick/Dropbox/EUR/R_work/r_website/r_website_project/themes/hugo-academic/layouts/partials/page_metadata.html:63:31": execute of template failed: template: partials/page_metadata.html:63:31: executing "partials/page_metadata.html" at <.>: range can't iterate over R
我的解决方案
对我来说,它有助于回滚到 blogdown 版本 0.20
,如下所示:
packageVersion("blogdown")
#> [1] '0.21'
library("devtools")
#> Loading required package: usethis
install_version("blogdown", version = "0.20", repos = "http://cran.us.r-project.org")
#> Downloading package from url: http://cran.us.r-project.org/src/contrib/Archive/blogdown/blogdown_0.20.tar.gz
packageVersion("blogdown")
#> [1] '0.20'
由 reprex package (v0.3.0)
于 2020-11-13 创建
现在一切都恢复“正常”了。
我看过关于 blogdown::serve_site()
no longer serving the site 的 post 并阅读了 blogdown 0.21 的发行说明,但这对我的问题没有帮助。
我的工作流程is/was写一个post,然后在RStudio中点击“Serve Site”,在我项目的public/文件夹中查看新生成的文件。我的 ShinyApps 目录中有一个该文件夹的符号 link,因此我可以通过 Shiny 服务器查看我的站点。这太棒了,因为这样我也使用该服务器的同事也可以看到我的站点。
现在这不再起作用了。当我直接在 RStudio 中获取更新后的站点时,Shiny 服务器显示的文件没有更新。我能找到的唯一解释是:
The global option blogdown.generator.server has been deprecated. Now blogdown::serve_site() always use the Hugo server (which corresponds to options(blogdown.generator.server = TRUE) in previous version of blogdown), instead of the server created via the servr package (which corresponds to the default options(blogdown.generator.server = FALSE) before).
我不太了解 Hugo,但我发现 hugo server
不会更新 public/ 目录,对吗?我现在可以做什么来更新它?
问题已经 answered on GitHub:
我需要使用 blogdown::build_site(local=TRUE)
.
编辑: 事实证明,以下对我来说也不是解决方案。因此,我 post 提出了一个可能的解决方法的问题:
Problem (and solution?) with rendering Hugo/blogdown site
较早(旧)post:
这对我没有帮助。更新 blogdown 并启动我的 R 项目时,blogdown:::preview_site(startup = TRUE)
会自动运行。我不记得早期初创企业的事情。我现在总是收到相同的错误消息:
Launching the server via the command: hugo server --bind 127.0.0.1 -p 4321 --themesDir themes -t hugo-academic -D -F --navigateToChanged sh: line 0: kill: (3262) - No such process Error: It took more than 30 seconds to launch the server. There may be something wrong. The process has been killed. If the site needs more time to be built and launched, set options(blogdown.server.timeout) to a larger value.
运行 blogdown::build_site(local = TRUE)
导致更长的错误消息,开头为:
ERROR 2020/11/13 15:55:56 render of "page" failed: execute of template failed: template: _default/single.html:6:5: executing "_default/single.html" at <partial "page_header.html" .>: error calling partial: execute of template failed: template: partials/page_header.html:92:7: executing "partials/page_header.html" at <partial "page_metadata" (dict "page" $page "is_list" 0 "share" true)>: error calling partial: "/Users/frederick/Dropbox/EUR/R_work/r_website/r_website_project/themes/hugo-academic/layouts/partials/page_metadata.html:63:31": execute of template failed: template: partials/page_metadata.html:63:31: executing "partials/page_metadata.html" at <.>: range can't iterate over R
我的解决方案
对我来说,它有助于回滚到 blogdown 版本 0.20
,如下所示:
packageVersion("blogdown")
#> [1] '0.21'
library("devtools")
#> Loading required package: usethis
install_version("blogdown", version = "0.20", repos = "http://cran.us.r-project.org")
#> Downloading package from url: http://cran.us.r-project.org/src/contrib/Archive/blogdown/blogdown_0.20.tar.gz
packageVersion("blogdown")
#> [1] '0.20'
由 reprex package (v0.3.0)
于 2020-11-13 创建现在一切都恢复“正常”了。