【问题标题】:Page not found with hugo on netlify在 netlify 上找不到带有 hugo 的页面
【发布时间】:2019-09-17 00:53:17
【问题描述】:

我最近翻译了一个我自己写的网站,所以我没有使用主题,我在 localhost 上对其进行了测试,它运行完美,但是,当我尝试在 netlify 上托管它时,我得到一个找不到页面的错误。我在 netlify.toml 文件和 netlify 的持续部署设置中都将发布目录设置为 public,如下所示:

netlify.toml,

[build]
publish = "public"
command = "hugo"

[context.production.environment]
HUGO_VERSION = "0.53"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"

[context.split1]
command = "hugo --enableGitInfo"

[context.split1.environment]
HUGO_VERSION = "0.53"
HUGO_ENV = "production"

[context.deploy-preview]
command = "hugo -b $DEPLOY_PRIME_URL"

[context.deploy-preview.environment]
HUGO_VERSION = "0.53"

[context.branch-deploy]
command = "hugo -b $DEPLOY_PRIME_URL"

[context.branch-deploy.environment]
HUGO_VERSION = "0.53"

[context.next.environment]
HUGO_ENABLEGITINFO = "true"

和:

我想我已经遵循了那里的所有指南,但似乎没有任何效果。

这是我在 github 上的 repo 的链接https://github.com/guidogr95/amazondigital

也是最后的部署日志:

7:31:10 PM: Build ready to start
7:31:14 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
7:31:14 PM: build-image tag: v3.3.2
7:31:14 PM: buildbot version: 38cc4984170575781fef71bee035f0855939acb8
7:31:15 PM: Fetching cached dependencies
7:31:15 PM: Starting to download cache of 99.9MB
7:31:15 PM: Finished downloading cache in 606.906388ms
7:31:15 PM: Starting to extract cache
7:31:19 PM: Finished extracting cache in 4.22330485s
7:31:20 PM: Finished fetching cache in 4.879888251s
7:31:20 PM: Starting to prepare the repo for build
7:31:20 PM: Preparing Git Reference refs/heads/master
7:31:20 PM: Found netlify.toml. Overriding site configuration
7:31:20 PM: Starting build script
7:31:20 PM: Installing dependencies
7:31:21 PM: Started restoring cached node version
7:31:24 PM: Finished restoring cached node version
7:31:25 PM: v10.16.3 is already installed.
7:31:26 PM: Now using node v10.16.3 (npm v6.9.0)
7:31:26 PM: Attempting ruby version 2.6.2, read from environment
7:31:28 PM: Using ruby version 2.6.2
7:31:28 PM: Using PHP version 5.6
7:31:28 PM: Installing Hugo 0.53
7:31:28 PM: Hugo Static Site Generator v0.53-8FC339DC2529FF77E494A1C12CD1FF9FBCB880A4/extended             
linux/amd64 BuildDate: 2018-12-24T08:38:38Z
7:31:28 PM: Started restoring cached go cache
7:31:28 PM: Finished restoring cached go cache
7:31:28 PM: unset GOOS;
7:31:28 PM: unset GOARCH;
7:31:28 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
7:31:28 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
7:31:28 PM: go version >&2;
7:31:28 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
7:31:28 PM: go version go1.12 linux/amd64
7:31:28 PM: Installing missing commands
7:31:28 PM: Verify run directory
7:31:28 PM: Executing user command: hugo
7:31:28 PM: Building sites …
7:31:29 PM:                    | EN
7:31:29 PM: +------------------+----+
7:31:29 PM: Pages            |  1
7:31:29 PM:   Paginator pages  |  0
7:31:29 PM:   Non-page files   |  0
7:31:29 PM:   Static files
7:31:29 PM:  | 69
7:31:29 PM:   Processed images |  0
7:31:29 PM:   Aliases          |  0
7:31:29 PM:   Sitemaps         |  1
7:31:29 PM:   Cleaned          |  0
7:31:29 PM: Total in 37 ms
7:31:29 PM: Skipping functions preparation step: no functions directory set
7:31:29 PM: Caching artifacts
7:31:29 PM: Started saving pip cache
7:31:29 PM: Finished saving pip cache
7:31:29 PM: Started saving emacs cask dependencies
7:31:29 PM: Finished saving emacs cask dependencies
7:31:29 PM: Started saving maven dependencies
7:31:29 PM: Starting post processing
7:31:29 PM: Finished saving maven dependencies
7:31:29 PM: Started saving boot dependencies
7:31:29 PM: Finished saving boot dependencies
7:31:29 PM: Started saving go dependencies
7:31:29 PM: Finished saving go dependencies
7:31:29 PM: Post processing done
7:31:29 PM: Build script success
7:31:29 PM: Starting to deploy site from 'public'
7:31:29 PM: Creating deploy tree 
7:31:29 PM: 0 new files to upload
7:31:29 PM: 0 new functions to upload
7:31:29 PM: Site is live
7:31:47 PM: Finished processing build request in 32.861294195s

当我下载部署文件时,我注意到没有 index.html,只有这些文件:

我尝试在本地环境中使用“hugo”命令并上传创建的公用文件夹,这样做会显示站点,但这不是正确的方法,我也想使用 netlify cms 和那个方法行不通。 请,任何帮助将不胜感激,在此先感谢

【问题讨论】:

  • 我以为我快疯了,但解决了这个问题。回答跟随。

标签: hugo netlify netlify-cms


【解决方案1】:

这里的问题是文件名的大小写问题。在某些情况下,Windows 会忽略大小写,当文件应该是小写时,它会解析大写文件的路径。本例中Netlify上的构建环境使用的是unix,所以Hugo看不到模板baseof.html

/layouts/_default/baseOf.html改为全小写/layouts/_default/baseof.html

【讨论】:

  • 他们说要避免评论谢谢,但我对你感激不尽,谢谢!
  • 是的,我们不应该要求检查正确答案?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-15
  • 2023-01-23
  • 2021-09-25
  • 2019-12-23
  • 1970-01-01
相关资源
最近更新 更多