首页 > 解决方案 > 在内容存储库hugo中添加html文件并将其链接到scss

问题描述

这是我的雨果网站的树:

.
├── archetypes
├── assets
├── config.toml
├── content
├── layouts
├── Makefile
├── node_modules
├── package.json
├── public
├── README.md
├── resources
├── static
└── www.deploy

我想知道是否可以在存储库/content中添加/page2/index.html,所以有/content/page2/index.html。通常存储库/内容中只有降价文件。我很确定这在某种程度上是可能的。

如果 /content 中可能有一个 html 文件,我如何将它链接到一个 scss 文件?scss 文件将存储在存储库 /assets/scss/pages2/pages.scss 中。

如果无法在 /content 中添加 html 文件,那么如何在 hugo 中添加新页面?在 /layout 文件夹中添加一个 html 文件: /layout/page2/index.html 链接到 /content/page2/index.md?

我很困扰。

标签: htmlsassmarkdownhugo

解决方案


里面的文件content/是源文件:用markdown、org-mode等编写的文件,会被站点渲染成html。所以这不是放置 html 文件的地方。

从您的问题下方的评论中,听起来您想要实现的是创建一个与您的网站通常呈现的页面不同的页面。

解决这个问题的方法是编辑布局。我需要有关您网站的更多信息才能回答具体信息。但事情最终会看起来像这样:

content/
  dir1/
    file1.md
    file2.md
    ...
  dir2/
    that-very-different-file.md

在布局中,您必须为外观截然不同的页面创建新布局。所以你的布局目录看起来像这样:

layouts/
  dir1/
    single.html
  dir2/
    single.html

中的single.html文件dir1包含常规文件的模板布局和single.html非常dir2不同页面的模板中的文件。


推荐阅读