草稿时由 netlify 呈现:在 yaml 中为 true [英] Drafts rendered by netlify when draft: true in yaml

查看:72
本文介绍了草稿时由 netlify 呈现:在 yaml 中为 true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从这个 github repo 运行 blogdown 站点,该站点由 Netlify 在 https://timmastny.rbind.io/

I am running at blogdown site from this github repo hosted by Netlify at https://timmastny.rbind.io/

在 website2/content/blog/我有两个帖子

In website2/content/blog/ I have two posts

2018-01-16-git-blogdown-project-workflow.Rmd

2018-01-13-bayesian-meta-analysis-powerlifting.Rmd

你可以看到在两个帖子的 YAML 中,我有 draft: true,在第二个帖子中我什至有 publishdate: '2018-01-20'这是在这篇文章的未来.

You can see that in the YAML of both posts, I have draft: true and in the second one I even have publishdate: '2018-01-20' which is in the future as of this post.

但是,将这些更改推送到 github 并使用干净的缓存部署 Netlify,在我的实际网站上,我仍然看到以下帖子:https://timmastny.rbind.io/

However, with these changes pushed to github and Netlify deployed with a clean cache, on my actual website I still see the posts: https://timmastny.rbind.io/

我对 draft: true 遗漏了什么?

我已经阅读了这些书的 2.3.1 和 D.3 部分,但我不确定.我也将 Hugo 更新到 0.32.4 并且正在使用 blogdown 的最新版本.

I've read sections 2.3.1 and D.3 of the books, but I'm not sure. I've also updated Hugo to 0.32.4 and am on the latest version of blogdown.

我删除了 public 文件夹并将 public 添加到 gitignore.Netlify 发布了一个 16 分钟的构建版本.但在实际网站上,我收到找不到页面错误.

I've deleted the public folder and added public to gitignore. Netlify had a 16 minute build which was published. But on the actual website I get a Page Not Found error.

这是日志:https://app.netlify.com/sites/timmastny/deploys/5a60c299df99532a0147c3d7

这是我在 Netlify 上的部署设置.它们应该与 blogdown 书的 3.1 中的建议相匹配:

Here's my deploy settings on Netlify. They should match the suggestions in 3.1 of the blogdown book:

部署设置

存储库:https://github.com/tmastny/website2

构建命令:hugo

发布目录:公开

生产分支:master

Production branch: master

分支部署:仅部署生产分支及其部署预览

Branch deploys: Deploy only the production branch and its deploy previews

公共部署日志:日志是公开的

Public deploy logs: Logs are public

构建环境变量:HUGO_VERSION 0.32.4

Build environment variables: HUGO_VERSION 0.32.4

推荐答案

我假设您使用 public 作为 Netlify 的部署文件夹.

I am going to assume you are using public as your deploy folder for Netlify.

您的公共文件夹在您的存储库中,因此它会被检出到 Netlify 站点,并且当您运行构建时,您的帖子已经存在于该文件夹中,因此它们总是会被部署.

Your public folder is in your repository, so it is checked out to the Netlify site and when you run your build your posts already exist in that folder, so they are always going to be deployed.

从您的项目中删除公共文件夹并为公共文件夹添加一个 .gitignore.

Delete the public folder from your project and add a .gitignore for the public folder.

部署应该在每次部署时构建新的公共文件夹,以便它可以将 CDN 与您的构建进行比较并仅复制正确的文件.

The deploy should build the public folder fresh on each deploy, so it can compare the CDN with your build and copy the correct files only.

Hugo 主题在 config.toml 中设置为 theme = "hugo-xmin".从 GitHub 检出存储库时,此主题文件夹为空.它在 Netlify 上也会为空,因此构建无效.

The Hugo theme is set to theme = "hugo-xmin" in the config.toml. When checking out the repository from GitHub, this theme folder is empty. It would be empty on Netlify as well, so the build becomes invalid.

config.toml 中更改为有效主题 theme = "hugo-lithium-theme" 并且构建开始创建您的网站页面.

Changed to a valid theme theme = "hugo-lithium-theme" in the config.toml and the build starts to create your site pages.

更新 draft: true.Rmd 不会忽略构建.

When updating draft: true in .Rmd does not ignore on build.

Hugo 不会为 .Rmd 处理您的内容,而是使用您创建的已处理 .html 文件中的内容.因此,您需要确保在构建之前将那些带有 draft: true 的文件的内容提交到您的存储库.

Hugo is not processing your content for .Rmd, it is using your content from the processed .html files created. So you need to make sure you are committing the content for those files with draft: true in them to your repository before a build.

这篇关于草稿时由 netlify 呈现:在 yaml 中为 true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆