【问题标题】:Hugo / Blogdown Images Fail to Render After GitHub/Netlify DeploymentHugo / Blogdown 图片在 GitHub/Netlify 部署后无法渲染
【发布时间】:2021-06-05 21:01:32
【问题描述】:

这是我第一次提问,如果我做了一些愚蠢的事情,请提前道歉。

我用 blogdown 发表了我的第三篇博文。我在前两个上使用了图像,一切都很顺利,但这是第一个由 R 代码创建图像的:

png_1 <- image_read_pdf("index_files/pdf_with_image_1.pdf")

print(png_1)

这创建了一个新文件夹,路径如下所示:

\content\pos​​t\2021-06-05-mining-text-from-pdf-files-part-3-pdf-with-an-image\index_files\figure-html\

图像本身以这种方式命名:unnamed-chunk-4-1.png

写完帖子后,我做了通常的 Git/GitHub 仪式,Netlify 似乎可以正常部署帖子。

但是,这是网站上的样子(图片未显示):

我尝试在 GitHub、RStudio 社区甚至这里阅读类似问题,但我没有找到问题的直接答案。

这是 html 代码的样子:

img src="{{< blogdown/postref >}}index_files/figure-html/unnamed-chunk-4-1.png" width="1650"

我还使用 blogdown::check_site() 来查看那里是否有任何内容。至少那里没有 [TODO]:

― Checking config.yaml
| Checking "baseURL" setting for Hugo...
○ Found baseURL = "https://youcanbeapirate.netlify.com/"; nothing to do here!
| Checking "ignoreFiles" setting for Hugo...
○ "ignoreFiles" looks good - nothing to do here!
| Checking setting for Hugo's Markdown renderer...
○ All set! Found the "unsafe" setting for goldmark.
― Check complete: config.yaml

― Checking .gitignore
| Checking for items to remove...
○ Nothing to see here - found no items to remove.
| Checking for items to change...
○ Nothing to see here - found no items to change.
| Checking for items you can safely ignore...
○ Found! You have safely ignored: Thumbs.db, .DS_Store
| Checking for items to ignore if you build the site on Netlify...
○ Found! You have safely ignored: /resources/, /public/
| Checking for files required by blogdown but not committed...
○ Great! Did not find such files.
― Check complete: .gitignore

― Checking Hugo
| Checking Hugo version...
○ Found Hugo. You are using Hugo 0.83.1.
| Checking .Rprofile for Hugo version used by blogdown...
○ blogdown is using Hugo 0.83.1 to build site locally.
― Check complete: Hugo

― Checking netlify.toml...
○ Found HUGO_VERSION = 0.83.1 in [build] context of netlify.toml.
| Checking that Netlify & local Hugo versions match...
○ It's a match! Blogdown and Netlify are using the same Hugo version (0.83.1).
| Checking that Netlify & local Hugo publish directories match...
○ Good to go - blogdown and Netlify are using the same publish directory: public
― Check complete: netlify.toml

― Checking content files
| Checking for validity of YAML metadata in posts...
○ All YAML metadata appears to be syntactically valid.
| Checking for previewed content that will not be published...
○ Found 0 files with future publish dates.
○ Found 0 files marked as drafts.
| Checking your R Markdown content...
○ All R Markdown files have been knitted.
○ All R Markdown output files are up to date with their source files.
| Checking for .html/.md files to clean up...
○ Found 0 duplicate .html output files.
○ Found 0 incompatible .html files to clean up.
| Checking for the unnecessary 'content/' directory in theme...
○ Great! Your theme does not contain the content/ directory.
― Check complete: Content

链接到GitHub repo

如果需要,我可以提供更多信息。

PS:我在RStudio Community 也提出了同样的问题

【问题讨论】:

  • 你试过blogdown::check_site()吗?
  • 谢谢@YihuiXie,我试过了,把结果加到问题里了。
  • 太棒了!结果似乎没有任何问题。然后我认为我们需要查看源代码,以便我们可以尝试自己重现问题。您是否有网站项目的公共 Github 存储库或类似的东西要分享?
  • 再次感谢@YihuiXie!在问题中添加了指向 repo 的链接。
  • 很抱歉打扰您,@YihuiXie,但您最终能否重现问题?

标签: netlify hugo blogdown


【解决方案1】:

在您最近发布的那个 repo 中,我发现有一个奇怪的文件 (https://github.com/AnttiRask/blog/blob/master/content/post/2021-06-05-mining-text-from-pdf-files-part-3-pdf-with-an-image/index.Rmd.lock~),我想这可能是导致问题的原因。我从头开始快速测试,如果我删除该文件并重新编写该 RMD 文件,它就可以工作。

【讨论】:

  • 感谢@ifendo 的建议。我删除了该文件并提出了一个新的拉取请求,以让 Netlify 在我发布新帖子的同时部署帖子的更新版本。虽然我确实设法更新了同样丢失的标签,但删除锁定文件对图像没有帮助。
猜你喜欢
  • 1970-01-01
  • 2021-08-30
  • 2021-09-25
  • 2021-02-06
  • 1970-01-01
  • 1970-01-01
  • 2022-01-14
  • 2023-03-23
相关资源
最近更新 更多