Unable to use Output Formats

Objective:

I wanted content files to render as per specified layout (which they do) and in specific extension (here md).

What I tried:

1.config.toml

baseURL = "http://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
uglyurls = true

# Change the suffix of the HTML output format from html (default) to md
[mediaTypes]
  [mediaTypes."text/html"]
    suffixes = ["md"]

# Redefine HTML to update its media type.
[outputFormats]
  [outputFormats.HTML]
    mediaType = "text/html"

2.config.toml

baseURL = "http://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
uglyurls = true

# There was a note on https://gohugo.io/templates/output-formats saying:
# Note that for the above to work, you also need to add an outputs definition in your site config.
# Didn't understand it properly, but I think this is what it meant.
# Please correct me if wrong.
[outputs]
  page = ["HTML"]

# Change the suffix of the HTML output format from html (default) to md
[mediaTypes]
  [mediaTypes."text/html"]
    suffixes = ["md"]

# Redefine HTML to update its media type.
[outputFormats]
  [outputFormats.HTML]
    mediaType = "text/html"

3.config.toml

baseURL = "http://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
uglyurls = true

Expected result:

Files appear in public directory (in proper subfolder) with extension .md

Actual result as per What I tried, in respective manner:

  1. No files (or pages) appear other than taxonomy pages (and folder)
  2. No files (or pages) appear other than taxonomy pages (and folder)
  3. Files appear with extension .html (though it is not what I wanted, it is working as it should)

Please help

If Iā€™m understanding you correctly, you probably want something like this:

[outputs]
  home = ["MD"]

[outputFormats]
  [outputFormats.MD]
    baseName = "index"
    isPlainText = true
    mediaType = "text/markdown"

[mediaTypes]
  [mediaTypes."text/markdown"]
    suffixes = ["md"]
1 Like

You should extend the [outputs] , look here

I defined different outputs im my sample here

@pointyfar Thanks for the input. But when I adjust config file as per your suggestion, in output files (pages) have the .html extension.

If Iā€™m understanding you correctly

What I am trying to do is to have the generated pages to have .md extension.

@ju52 Thanks for the help. I had actually gone through the link you provided (from where I have quoted the note in point 2 of what I have tried).

What I am trying to do is to have generated pages to have .md extension. How may I declare output formats in config file? I think I should be concentrating on page in:

# quoted from https://github.com/gj52/HugoSample/blob/master/config/_default/config.toml
# on line no. 137 (at commit https://github.com/gj52/HugoSample/commit/0231cb59be80b8d70273ee1a09e297ed94f91539,
# just in case file changes in future)
[outputs]
    home                  = [ "HTML", "ATOM", "JSON", "FEED", "MANIFEST", "SITEMAP"]
    section               = [ "HTML", "SITEMAP" ]
    page                  = [ "HTML" ]
    taxonomy              = [ "HTML" ]
    taxonomyTerm          = [ "HTML" ]

Thoughts?

Do you have your site code somewhere we can have a look at? It would be easier to help you if we can see what you are doing.

You MUST create the correct templates for it!
Try to create a layouts/index.md template.

look here

Awesome!
I just changed the extension of my template file from .html to .md. It worked.

Current config.toml:

baseURL = "http://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
uglyurls = true

[outputFormats]
  [outputFormats.MD]
    baseName = "index"
    isPlainText = true
    mediaType = "text/markdown"

[mediaTypes]
  [mediaTypes."text/markdown"]
    suffixes = ["md"]

[outputs]
  page = ["MD"]

Thanks a lot!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.