2

Bonjour !

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>

Thank for help

SuperStormer
  • 4,997
  • 5
  • 25
  • 35
Lynow
  • 21
  • 3
  • Hello Cyprien, a few clarifications: 1) Why do you have an RSS feed in a question about outputting txt files how is this connected? 2) Did outputting the markdown file as text not work (https://gohugo.io/templates/output-formats#customizing-output-formats)? – Rogelio Jan 24 '22 at 18:16
  • Bobjour Rogelio, thank you for your answer! Indeed, I don't know why I have RSS feeds, yet I haven't configured anything of this type in the site's "config.toml" file. For the "Output Formats", I did not understand how I had to specify that for a specific page, such as the "security" page, the output must be in txt format. How to use the syntax for the config.toml file? – Lynow Jan 26 '22 at 09:40

1 Answers1

0

Bonjour Cyprien, If you permit me, I think I understand the deeper confusion you may have and will answer that. 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).

Rogelio
  • 910
  • 5
  • 14
  • Hey Rogelio, Thank you very much for your explanation, indeed I had not understood how the "Output format" worked. I have now managed to do what I wanted, thank you very much! (live from France) Beautiful day – Lynow Jan 27 '22 at 08:11
  • Awesome Cyprien, good to know, now if this was the right answer - "check" it so it is marked as closed. – Rogelio Jan 28 '22 at 17:34