【问题标题】:How to embbed a local html in a hugo post: specify the location of the html file如何在hugo帖子中嵌入本地html:指定html文件的位置
【发布时间】:2022-10-02 01:00:26
【问题描述】:

我正在尝试将本地 html 文件(作为 iframe)嵌入到 hugo 帖子中,但是我不太明白 html 文件应该放在哪里。

在类似的post 中提到了以下代码,但我对program 文件夹的位置感到困惑

---
title : \"Hello World\"
summary : \"Simple program\"
url : \"program/helloworld\"
--- 
<iframe width=\"100%\" height=\"150\" name=\"iframe\" src=\"dashboard.html\"></iframe>

在另一个post 上,描述了以下解决方案,但不清楚第二部分应该放在哪里(在降价文件中还是短代码),也不清楚target_asset_name 是否应该只包含文件名(带扩展名)或者它可以是iframe_assests_root 中的子文件夹

---
iframeSource: \"target_asset_name\"
---

{{- $srcurl := (print .Site.BaseURL \"iframe_assests_root/\" .Params.iframeSource \"/\") -}}
<iframe src=\"{{- $srcurl -}}\"></iframe>

如果有人可以就上述任何答案提供更具体的示例,我将不胜感激。谢谢...

    标签: iframe local hugo


    【解决方案1】:
    ---
    title : "Hello World"
    summary : "Simple program"
    url : "program/helloworld"
    --- 
    <iframe width="100%" height="150" name="iframe" src="dashboard.html"></iframe>
    

    上面的代码意味着您的父页面位于https://www.yourdomain.com/program/helloworld(“url”)。在这种情况下,“dashboard.html”文件应该放在你的“静态”目录中,该目录位于项目的根目录中。

    【讨论】:

      【解决方案2】:

      感谢您的答复。不幸的是,我仍然对“程序/helloword”如何映射到内容/帖子文件夹感到困惑。但是,在阅读了 Brian Hogan 的“使用 Hugo 构建网站”之后,我能够通过使用页面包.对于那些不熟悉 Hugo 语法的人(像我一样),它基本上涉及使用帖子名称(例如 content/posts/iframe)创建一个文件夹,并在其中创建:一个名为 index.md 的降价文件和一个文件夹,其中 html 文件将去(例如content/posts/iframe/iframes)。然后,使用以下命令将 iframe 嵌入到降价文件中:

      <iframe width="100%" height="550" name="iframe" src="iframes/myhtml.html"></iframe>
      

      在找到更好的解决方案之前,我仍然需要阅读更多关于页面包、短代码以及如何定义和访问变量的信息,但目前上述内容似乎有效......

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-03-03
        • 1970-01-01
        • 2013-10-19
        • 1970-01-01
        • 2012-09-24
        • 2020-03-02
        相关资源
        最近更新 更多