将 Hugo 网站部署到 Google Cloud 应用程序引擎时出现问题

发布于 2025-01-12 03:29:20 字数 1106 浏览 5 评论 0原文

所以我正在尝试将我的 Hugo 博客部署到谷歌云应用程序引擎,但我遇到了 URL 映射问题,我已经玩了很多次,但似乎没有任何作用

主页正在工作,我可以看到帖子,但当我点击帖子时出现错误:未找到消息

app.yaml

env: standard
runtime: nodejs16
service: default
handlers:
  - url: /
    static_files: public/index.html
    upload: public/index.html
  - url: /posts
    static_dir: public/posts
  - url: /(.*)
    static_files: public/\1
    upload: public/(.*)

文件结构

在此处输入图像描述

网站链接:https://www.waelfadlallah.com/


感谢 NoCommandLine 问题已解决,这是我的 app.yaml 现在的样子

env: standard
runtime: nodejs16
service: default
handlers:
  - url: /posts/(.+)/
    static_files: public/posts/\1/index.html
    upload: public/posts/(.+)/index.html
  - url: /assets
    static_dir: public/assets
  - url: /
    static_files: public/index.html
    upload: public/index.html

So I'm trying to deploy my Hugo blog to google cloud app engine, but I'm having issue with the URL mapping,I have played with it a lot but nothing seem to work

The home page is working and I can see the the posts but when I click on a post I got error: Not Found message

app.yaml

env: standard
runtime: nodejs16
service: default
handlers:
  - url: /
    static_files: public/index.html
    upload: public/index.html
  - url: /posts
    static_dir: public/posts
  - url: /(.*)
    static_files: public/\1
    upload: public/(.*)

Files structure

enter image description here

website link: https://www.waelfadlallah.com/


Thank to NoCommandLine the issue is resolved, here is how my app.yaml looks like now

env: standard
runtime: nodejs16
service: default
handlers:
  - url: /posts/(.+)/
    static_files: public/posts/\1/index.html
    upload: public/posts/(.+)/index.html
  - url: /assets
    static_dir: public/assets
  - url: /
    static_files: public/index.html
    upload: public/index.html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谢绝鈎搭 2025-01-19 03:29:21

看看这是否有效......

而不是使用 static_dir,而是尝试使用 static_files 并让你的处理程序像示例 此处。该示例有(下面的示例)。看看是否可以修改它以适合您的模式

- url: /([^\.]+)([^/])
  static_files: www/\1\2/index.html
  upload: www/(.+)

See if this works....

Instead of using static_dir, try using static_files and have your handler like the example here. That example has (the sample below). See if you can modify it to suit your pattern

- url: /([^\.]+)([^/])
  static_files: www/\1\2/index.html
  upload: www/(.+)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文