Hugo: creation of a page that sends to a txt format

640 views Asked by At

I want to create a page that sends directly to a page in txt format, i.e. with a path like this: www.siteweb.fr/securite.txt

The problem is that when I create a new security page > _index.md, I have this front matter:

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

Here I can't assign a txt page directly, like I can with html ().

I tried adding the "url" option in the front matter, but when I do that, I have the path with the txt file but there is an XML format that is done on the page. I don't know how to remedy this :

<?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>
1

There are 1 answers

1
Rogelio On

The below is a very loose/workable definition and you should check the docs, but it gives a sort of understanding:

  1. When you type "hugo" in command line, that outputs your entire site in the public folder.
  2. When you type "hugo server" in command line, that redirects this output to a local server.

But, what does it build, RSS, HTML, text?

One of the options/parameters Hugo uses to build is what is in your config, example:

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

This is my config, and states that my pages - output as html. Home outputs as HTML, RSS and JSON. Section outputs as HTML and RSS.

Now this is SITE WIDE.

So, with that orientation, see the below PAGE front matter to go in a specific page:

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

If you would like to check the docs: https://gohugo.io/variables/page/ https://gohugo.io/templates/output-formats/#customizing-output-formats

Particularly clarifying is: https://discourse.gohugo.io/t/custom-output-formats/33481/5 (If you try to get fancy that is).