我按照https://bookdown.org/yihui/blogdown/a-quick-example.html#create-project的指示运行blogdown,第一次创建自行下载了最新的Hugo,之后的操作和指示里的说明一致,模板选择了yihui/hugo-lithium。但最后创建项目的时候右下角的File里面仅有一个.Rproj文件,没有.yaml文件、.Rmd文件和netlify.toml文件。

创建项目后控制台显示如下报错信息:
― Creating your new site
Error: command error: unknown shorthand flag: 'f' in -f

应该是因为这个报错导致其余文件没有生成,仅仅只有一个.Rproj文件,请问如何解决?

    yihui 感谢回复!我运行了你提供的以下代码:

    remotes::install_github('rstudio/blogdown')

    运行之后系统询问我是否需要更新相关的所有的包,我选择了全部更新,但是似乎xfun包无法更新

    程序包‘rlang’打开成功,MD5和检查也通过
    程序包‘later’打开成功,MD5和检查也通过
    程序包‘vctrs’打开成功,MD5和检查也通过
    程序包‘fs’打开成功,MD5和检查也通过
    程序包‘cachem’打开成功,MD5和检查也通过
    程序包‘sass’打开成功,MD5和检查也通过
    程序包‘xfun’打开成功,MD5和检查也通过
    Warning: 无法将拆除原来安装的程序包‘xfun’
    Warning: 回复了‘xfun’
    程序包‘tinytex’打开成功,MD5和检查也通过
    程序包‘fontawesome’打开成功,MD5和检查也通过
    程序包‘httpuv’打开成功,MD5和检查也通过
    程序包‘servr’打开成功,MD5和检查也通过
    程序包‘bookdown’打开成功,MD5和检查也通过
    
    下载的二进制程序包在
    	C:\Users\Sonde\AppData\Local\Temp\RtmpWOFtaq\downloaded_packages里
    ── R CMD build ────────────────────────────────────────────────────────────────────
    ✔  checking for file 'C:\Users\Sonde\AppData\Local\Temp\RtmpWOFtaq\remotes3ac43d4a34a7\rstudio-blogdown-75e4855/DESCRIPTION' ... 
    ─  preparing 'blogdown':
    ✔  checking DESCRIPTION meta-information ... 
    ─  checking for LF line-endings in source and make files and shell scripts
    ─  checking for empty or unneeded directories
    ─  building 'blogdown_1.17.2.tar.gz'
       
    * installing *source* package 'blogdown' ...
    ** using staged installation
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    *** copying figures
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
    * DONE (blogdown)
    Warning message:
    In file.copy(savedcopy, lib, recursive = TRUE) :
      problem copying D:\StatisticsSoftware\R\R-4.2.3\library\00LOCK\xfun\libs\x64\xfun.dll to D:\StatisticsSoftware\R\R-4.2.3\library\xfun\libs\x64\xfun.dll: Permission denied

    我试着再创建一次blogdown,但仍然显示― Creating your new site
    Error: command error: unknown shorthand flag: 'f' in -f
    。不知道是否因为xfun包更新失败,我packages中看到还是0.38(本应升级到0.39)。

      dryezl 你好!我到文件夹手动删除了xfun包,并运行了remotes::install_github('rstudio/blogdown', force = TRUE),最后成功下载最新的xfun包。

      再次创建新的blogdown项目,运行结果如下:

      ― Creating your new site
      | Installing the theme yihui/hugo-lithium from github.com
      trying URL 'https://github.com/yihui/hugo-lithium/archive/HEAD.tar.gz'
      Content type 'application/x-gzip' length unknown
      downloaded 109 KB
      
      | Adding the sample post to content/post/2020-12-01-r-rmarkdown/index.Rmd
      | Converting all metadata to the YAML format
      | Adding netlify.toml in case you want to deploy the site to Netlify
      | Adding .Rprofile to set options() for blogdown
      ― The new site is ready
      ○ To start a local preview: use blogdown::serve_site(), or the RStudio add-in "Serve Site"
      ○ To stop a local preview: use blogdown::stop_server(), or restart your R session

      这一次文件夹File内已正常显示.yaml.Rmd等多个文件。

      新的问题

      虽然解决了文件栏里存在文件缺失的问题,但在建站时遇到了很多报错信息。

      运行blogdown:::serve_site()时显示:

      Launching the server via the command:
      C:/Users/Sonde/AppData/Roaming/Hugo/0.112.2/hugo.exe server --bind 127.0.0.1 -p 4321 --themesDir themes -t hugo-lithium -D -F --navigateToChanged
      Error: error building site: render: failed to render pages: render of "taxonomy" failed: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\_default\list.html:35:3": execute of template failed: template: default/list.html:35:3: executing "default/list.html" at <partial "footer.html" .>: error calling partial: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\partials\footer.html:4:29": execute of template failed: template: partials/footer.html:4:29: executing "partials/footer.html" at <.Site.RSSLink>: can't evaluate field RSSLink in type page.Site

      我在论坛里其他跟serve_site相关的求助帖子里看到可以使用blogdown::build_site()查看问题,运行之后发现很多报错。

      blogdown::build_site()

      Start building sites …
      hugo v0.112.2-f89108f2b1b299421cb830777994d6e61dc10755+extended windows/amd64 BuildDate=2023-05-24T10:45:31Z VendorInfo=gohugoio
      ERROR 2023/05/25 15:37:17 render of "page" failed: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\_default\single.html:25:3": execute of template failed: template: default/single.html:25:3: executing "default/single.html" at <partial "footer.html" .>: error calling partial: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\partials\footer.html:4:29": execute of template failed: template: partials/footer.html:4:29: executing "partials/footer.html" at <.Site.RSSLink>: can't evaluate field RSSLink in type page.Site
      ERROR 2023/05/25 15:37:17 render of "section" failed: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\_default\list.html:35:3": execute of template failed: template: default/list.html:35:3: executing "default/list.html" at <partial "footer.html" .>: error calling partial: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\partials\footer.html:4:29": execute of template failed: template: partials/footer.html:4:29: executing "partials/footer.html" at <.Site.RSSLink>: can't evaluate field RSSLink in type page.Site
      ERROR 2023/05/25 15:37:17 render of "taxonomy" failed: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\_default\list.html:35:3": execute of template failed: template: default/list.html:35:3: executing "default/list.html" at <partial "footer.html" .>: error calling partial: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\partials\footer.html:4:29": execute of template failed: template: partials/footer.html:4:29: executing "partials/footer.html" at <.Site.RSSLink>: can't evaluate field RSSLink in type page.Site
      ERROR 2023/05/25 15:37:17 render of "home" failed: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\_default\list.html:35:3": execute of template failed: template: default/list.html:35:3: executing "default/list.html" at <partial "footer.html" .>: error calling partial: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\partials\footer.html:4:29": execute of template failed: template: partials/footer.html:4:29: executing "partials/footer.html" at <.Site.RSSLink>: can't evaluate field RSSLink in type page.Site
      Total in 44 ms
      Error: error building site: render: failed to render pages: render of "taxonomy" failed: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\_default\list.html:35:3": execute of template failed: template: default/list.html:35:3: executing "default/list.html" at <partial "footer.html" .>: error calling partial: "D:\02_work\values\myblog\themes\hugo-lithium\layouts\partials\footer.html:4:29": execute of template failed: template: partials/footer.html:4:29: executing "partials/footer.html" at <.Site.RSSLink>: can't evaluate field RSSLink in type page.Site

      系统信息

      R version 4.2.3 (2023-03-15 ucrt)
      Platform: x86_64-w64-mingw32/x64 (64-bit)
      Running under: Windows 10 x64 (build 22621)

      Matrix products: default

      locale:
      [1] LC_COLLATE=Chinese (Simplified)China.utf8
      [2] LC_CTYPE=Chinese (Simplified)
      China.utf8
      [3] LC_MONETARY=Chinese (Simplified)China.utf8
      [4] LC_NUMERIC=C
      [5] LC_TIME=Chinese (Simplified)
      China.utf8

      attached base packages:
      [1] stats graphics grDevices utils datasets methods base

      other attached packages:
      [1] blogdown_1.17.2

      loaded via a namespace (and not attached):
      [1] Rcpp_1.0.10 ps_1.7.3 later_1.3.1 digest_0.6.31
      [5] R6_2.5.1 jsonlite_1.8.4 magrittr_2.0.3 evaluate_0.21
      [9] rlang_1.1.1 cli_3.6.1 promises_1.2.0.1 rstudioapi_0.14
      [13] rmarkdown_2.21 tools_4.2.3 servr_0.27 processx_3.8.0
      [17] httpuv_1.6.11 xfun_0.39 yaml_2.3.7 rsconnect_0.8.29
      [21] fastmap_1.1.1 compiler_4.2.3 htmltools_0.5.5 knitr_1.42

      麻烦大家不吝赐教,万分感谢!

        residual-sun 你没有遵医嘱啊,上面我建议你使用 hugo v0.111.3,但你仍然用了 v0.112.2。0.112.x 这个系列版本一堆重大缺陷,开发者急于求成,结果两天内连续放出了好几个补丁版本,到现在还没补完。开发软件在没有足够测试的情况下急于求成,就跟不系安全带飙车一样。

        blogdown::remove_hugo('0.112.2')
        blogdown::install_hugo('0.111.3')

        并在 .Rprofile 中将版本号改过来,重启 R。

          yihui 锁定一个能用的版本真的很重要,一路升级 Hugo 不知道啥时候会出问题。

          yihui 感谢谢大哥!问题已解决!

          我当时心急人也懵,没有仔细看,以为下载谢大哥你修复的blogdown就没问题了,没理解Hugo是单独的.exe程序。现在对症下药,删除0.112.2,并下载0.111.3之后建站畅通无阻(我也到我的.Rprofile看了一下,没有找到关于Hugo使用的版本设置,这样直接删除0.112.2,R应该是会自行识别使用0.111.3)。

          感谢谢大哥的耐心指正!