【问题标题】:Hugo blog + netlify deployment + custom domain = page not found..frustrating stuffHugo 博客 + netlify 部署 + 自定义域 = 找不到页面..令人沮丧的东西
【发布时间】:2019-04-15 00:57:42
【问题描述】:

无论我做什么,我都会不断收到找不到页面的错误。 两个 url,我的自定义域 (https://dittmaraz.life) 和 netlify 的子域 (https://compassionate-lumiere-512b58.netlify.com) 都给我“找不到页面”。这是一个错误页面,上面写着:

页面未找到 您似乎点击了一个损坏的链接或输入了该网站上不存在的网址。

这里是 github repo

没有构建错误。有一篇博客文章,其草稿属性设置为 false。 netlify 的构建设置设置为初始设置。 此外,config.toml 的 baseURL 设置为 'https://dittmaraz.life/'。

有什么建议吗?

【问题讨论】:

    标签: hugo netlify


    【解决方案1】:

    您正在使用默认部署文件夹 public,但您的站点的 config.toml 正在部署到 docs

    baseURL = "https://dittmaraz.life/"
    languageCode = "en-us"
    title = "dittmaraz"
    theme = "mediumish-gohugo-theme"
    summaryLength = 25
    copyright = "2019 dittmaraz.life"
    enableEmoji = true
    publishDir = "docs"
    
    

    您可以在站点的 app.netlify.com 管理控制台中更改此设置,或在存储库的根目录中创建 netlify.toml

    netlify.toml

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

    或者,您可以通过将值从 docs 更改为 public 来将其部署到 public

    【讨论】:

    • 如果您遇到此问题并且没有@talves 发布的解决方案,请在此处查看有关此问题的一般原因以及如何解决问题的文章:community.netlify.com/t/…
    【解决方案2】:

    我看到两个问题:

    错误的发布目录:

    正如Talves 已经指出的那样,内容生成到 /docs 而不是默认的 /public 目录。轻松修复,将 publishDirconfig.toml 中注释掉:

    #publishDir = "docs"
    

    在 Git 存储库中生成的内容:

    Netlify 将生成您的站点,它不应该在 Git 存储库中。

    1. 删除目录 /public 和 /docs
    2. 提交给 Git
    3. 使用此内容添加 .gitignore:

      /公共/ /资源/

    【讨论】:

      猜你喜欢
      • 2021-01-24
      • 2012-12-17
      • 1970-01-01
      • 1970-01-01
      • 2022-12-15
      • 1970-01-01
      • 2013-01-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多