r - "Page Not Found"尝试访问部署在 Netlify 上的站点时

标签 r hugo blogdown netlify

我正在运行一个静态 blogdown站点并将其部署在 Netlify 上。我在 GitHub 上获取源文件,Hugo 构建站点,Netlify 部署它。
Netlify 报告该站点处于事件状态(部署日志包含在底部),但是当我尝试查看我的站点时,我看到的只是一条 Netlify 错误消息:

Page Not found

Looks like you've followed a broken link or entered a URL that doesn't exist on this site.

← Back to our site


可能是什么原因?

我的 GitHub 存储库:https://github.com/taraskaduk/taraskaduk
我的网址应该是:https://taraskaduk.com/
我的部署设置:
Repository: https://github.com/taraskaduk/taraskaduk
Build command: hugo
Publish directory: public
Production branch: master
Branch deploys: Deploy only the production branch and its deploy previews
Public deploy logs: Logs are public
Hugo 版本(我尝试了不同的版本)HUGO_VERSION 0.37.1我最新的部署日志:
9:56:27 PM: Build ready to start
9:56:28 PM: Fetching cached dependencies
9:56:29 PM: Starting to download cache of 172.4MB
9:56:30 PM: Finished downloading cache in 1.74774892s
9:56:30 PM: Starting to extract cache
9:56:33 PM: Finished extracting cache in 2.59393707s
9:56:33 PM: Finished fetching cache in 4.428746301s
9:56:33 PM: Starting to prepare the repo for build
9:56:33 PM: Preparing Git Reference refs/heads/master
9:56:34 PM: Starting build script
9:56:34 PM: Installing dependencies
9:56:35 PM: Started restoring cached node version
9:56:37 PM: Finished restoring cached node version
9:56:37 PM: v8.11.2 is already installed.
9:56:38 PM: Now using node v8.11.2 (npm v5.6.0)
9:56:38 PM: Attempting ruby version 2.3.6, read from environment
9:56:39 PM: Using ruby version 2.3.6
9:56:39 PM: Using PHP version 5.6
9:56:39 PM: Installing Hugo 0.37.1
9:56:39 PM: Started restoring cached go cache
9:56:39 PM: Finished restoring cached go cache
9:56:39 PM: unset GOOS;
9:56:39 PM: unset GOARCH;
9:56:39 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.10.linux.amd64';
9:56:39 PM: export PATH="/opt/buildhome/.gimme/versions/go1.10.linux.amd64/bin:${PATH}";
9:56:39 PM: go version >&2;
9:56:39 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.10.linux.amd64.env';
9:56:39 PM: go version go1.10 linux/amd64
9:56:39 PM: Installing missing commands
9:56:40 PM: Verify run directory
9:56:40 PM: Executing user command: hugo
9:56:40 PM: Building sites …
9:56:40 PM: 
9:56:40 PM:                    | EN
9:56:40 PM: +------------------+----+
9:56:40 PM:   Pages            |  6
9:56:40 PM:   Paginator pages  |  0
9:56:40 PM:   Non-page files   | 49
9:56:40 PM:   Static files     | 39
9:56:40 PM:   Processed images |  0
9:56:40 PM:   Aliases          |  4
9:56:40 PM:   Sitemaps         |  1
9:56:40 PM:   Cleaned          |  0
9:56:40 PM: Total in 522 ms
9:56:40 PM: Caching artifacts
9:56:40 PM: Started saving pip cache
9:56:40 PM: Finished saving pip cache
9:56:40 PM: Started saving emacs cask dependencies
9:56:40 PM: Finished saving emacs cask dependencies
9:56:40 PM: Started saving maven dependencies
9:56:40 PM: Finished saving maven dependencies
9:56:40 PM: Started saving boot dependencies
9:56:40 PM: Finished saving boot dependencies
9:56:40 PM: Started saving go dependencies
9:56:40 PM: Finished saving go dependencies
9:56:40 PM: Build script success
9:56:40 PM: Starting to deploy site from 'public'
9:56:41 PM: Starting post processing
9:56:41 PM: Post processing done
9:56:41 PM: Site is live

最佳答案

免责声明:我在支持团队@Netlify 工作

尽管我们只能真正帮助您调试我们的构建过程与您本地的不同之处,而不是调试您的源代码,但始终允许就此类问题联系 Netlify 支持。让我扩展评论者提出的一些最佳实践,并提供一些建议以帮助您进一步调试不明显的。

首先,按照建议(感谢@aosmith!)BaseURL 应该设置为/- 这是最佳实践,并且允许您的站点在本地工作 ( http://localhost ) 以及 Netlify - 通过 http、https、deploy previews ,最后在其他托管服务提供商上,而代理则是等等。就去做吧:)

其次,您不仅可以在 _redirects 中进行重定向文件还要netlify.toml ,但我也不认为这是这里的问题。

当您的主 URL 出现 404 时,这意味着您没有/index.html 。根本原因是什么,我不知道(尽管我可以说当您的主题丢失并且可能无法生成您期望的内容时,hugo 不喜欢它)。有两种很好的方法可以弄清楚为什么我们的构建没有在您的发布文件夹( public ,在您的情况下和默认的 Hugo 配置)中生成 index.html :

  • 您可以从我的屏幕截图中显示的部署日志页面下载任何成功部署的副本,然后查看“我们最终得到了什么”。这里的典型问题是我们什么都没有(你的构建没有公开/或者你最终没有 index.html - 所以我们正确地显示了一个没有路径的 404)
  • 您可以按照调试说明在本地运行我们的构建镜像:https://github.com/netlify/build-image#testing-locally .构建完成后,您仍处于构建 shell 中,可以查看发布目录中的内容。

  • screenshot indicating deploy download location

    关于r - "Page Not Found"尝试访问部署在 Netlify 上的站点时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50752350/

    相关文章:

    R中真正快速的单词ngram矢量化

    r - 使用 "details"HTML 标签切换 block 输出

    git - Hugo - 多语言支持错误

    r - Blogdown 网站帖子 - 隐藏日期和/或帖子标题

    r - 使用 broom 包整理 map 时保留区域名称

    debugging - 没有抛出错误的错误

    dns - 如何设置DNS,让一个gitlab页面的根域和子域指向同一个地址?

    javascript - 使用 AWS Lambda 自动创建静态站点客户端页面

    r - 如何在 .Rmd 文件中为帖子添加功能或缩略图

    r - 当草稿 : true in yaml 时由 netlify 渲染的草稿