Hugo:创建发送到 txt 格式的页面

问题描述 投票:0回答:1

我想创建一个直接发送到txt格式页面的页面,即路径如下:www.siteweb.fr/securite.txt

问题是,当我创建一个新的安全页面> _index.md时,我有这个前面的问题:

---
title: "Security"
featured_image: '...'
---
Text Text

这里我不能像用html()那样直接分配一个txt页面。

我尝试在前面的内容中添加“url”选项,但是当我这样做时,我有txt文件的路径,但页面上有一个XML格式。我不知道如何解决这个问题:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Sécurité on blog</title>
    <link>http://192.168.x.x/fr/securite.txt</link>
    <description>Recent content in Sécurité on blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    
    <atom:link href="http://192.168.x.x/securite.txt" rel="self" type="application/rss+xml" />
    
    
  </channel>
</rss>
hugo hugo-shortcode hugo-content-organization
1个回答
0
投票

下面是一个非常宽松/可行的定义,您应该检查文档,但它给出了一种理解:

  1. 当您在命令行中键入“hugo”时,会在公共文件夹中输出整个站点。
  2. 当您在命令行中键入“hugo server”时,会将此输出重定向到本地服务器。

但是,它构建什么,RSS、HTML、文本?

Hugo 用于构建的选项/参数之一是您的配置中的内容,例如:

  page = ["HTML"]
  home = ["HTML", "RSS", "JSON"]
  section = ["HTML","RSS"]

这是我的配置,并指出我的页面 - 输出为 html。 主页输出为 HTML、RSS 和 JSON。 部分输出为 HTML 和 RSS。

现在这是全站范围。

因此,按照这个方向,请参阅下面的页面首页内容以进入特定页面:

---
date: "2016-03-19"
outputs:
- html
- txt
- json
---

如果您想查看文档: https://gohugo.io/variables/page/ https://gohugo.io/templates/output-formats/#customizing-output-formats

特别澄清的是: https://discourse.gohugo.io/t/custom-output-formats/33481/5 (如果你想变得更奇特的话)。

© www.soinside.com 2019 - 2024. All rights reserved.