【问题标题】:HUGO URL: triggering the default single page of the layouts when I don't want toHUGO URL:当我不想触发布局的默认单页时
【发布时间】:2020-11-18 20:39:45
【问题描述】:

从我的角度来看,我的问题很简单,但我正在努力解决它。

在我的 Hugo 文件夹上,如果我恢复我的 layoutscontent 文件夹的结构,它是这样的:

layouts
  |--- _default
    |--- baseof.html
    |--- list.html
    |--- single.html
  |--- blog
    |--- list.html
    |--- single.html

content
  |--- blog
    |--- posts

/layouts/blog/list.html 下的代码运行良好——本地http://localhost:1313/blog/ 上的 URL 下的列表页面的设计是我想要的。 但是/layouts/blog/single.html 下的代码不起作用。反而得到了/layouts/_default/single.html下单页的代码实现。

这个问题的根源可能在于我将我的博客文章从带有插件的 WordPress 迁移到了 Hugo。而我博文的元数据是这样的:

---
title: ...
author: ...
type: post
date: ...
url: /2020/10/title-of-the-post/
---

我在本地发帖的网址是:http://localhost:1313/2020/10/title-of-the-post/

我所做的显然是将帖子元数据中的网址更改为这样:

---
url: /blog/2020/10/title-of-the-post/
---

因此,我在本地的帖子的 URL 现在是:http://localhost:1313/blog/2020/10/title-of-the-post/

但是,它并没有触发/layouts/blog/single.html下的单页——实现的代码仍然是/layouts/_default/single.html下的那个。

我没有更多的想法可以尝试。你们中有人知道我该怎么做吗?

这是我来自config.toml 的永久链接配置,我猜你们中的一些人可能会问他们:

[permalinks]
  post = "/:year/:month/:title/"

【问题讨论】:

    标签: hugo


    【解决方案1】:

    我最终找到了解决方案:将我帖子前面的type: post行删除(或将其更改为type: blog)。

    【讨论】:

      猜你喜欢
      • 2020-02-02
      • 1970-01-01
      • 1970-01-01
      • 2021-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多