What is required to make markdown get picked up?

I am trying to build a site that is harvesting markdown from multiple git repos. It seems to ignore most of the markdown files, even though it copies all of the other files, like images, code etc. I cant guarantee that there will be an _index.md since I am not the author. Most sites use README.md as the index. But hugo is ignoring that file.

Not sure how advanced you are with Hugo. But you should check Hugo Modules and the Mount settings.

This will allow you to take any files, from any source and mount them at the desired location of your Hugo Project.

1 Like

I’m brand new to hugo. I’ve used mkdocs quite a bit, and am trying to convert an mkdocs site to hugo. The problem is not the directories. My directorie’s hierarchical (i use submodules to checkout everything I need as a child of the content directory. My problem is that where I have a .md in my content directories, nothing at all i written to the public directory. The directory is there, and all the not markdown content gets copied, but the markdown turns into nothing.

Markdown files need to have front matter for Hugo to generate the respective HTML pages.

1 Like

hmm. that kind of sucks. my whole use case is harvesting markdown from other authors who don’t know I’m using hugo. Can you have a default front matter that is applied is none is in a file?

Not with Hugo but currently there is an open issue about this feature: Allow Hugo to parse "plain" Markdown · Issue #6098 · gohugoio/hugo · GitHub

I suppose that you could write a script to prepend the needed front matter in the content files.

Thanks, at least I know it’s not just me :slight_smile:

I’ll watch that issue.

I’m curious to see what happens if you use cascade this is suppose to add the same front matter values to all descendents of a page. So if you add _index.md at the root of content/ with

cascade:
  title: Dummy Title

Then all descendents will share that title, and Hugo might build the pages as it picks some Front Matter form the cascade object. I never tried it and it might not suit your need, but I’m curious,

Actually the results of what you suggest @regis are surprising!

With the following tree:

content
├── _index.md
├── goodbye.md
└── hello.md

hello.md and goodbye.md contain no front matter.

_index.md contains:

cascade:
  title: Dummy Title

Hugo publishes both /hello/ and /goodbye/ despite the omission of front matter.

The downside is the lack of a customized title for those pages but I suppose that one could make a check in the template and provide a title by using for example the .File.BaseFileName variable (or something else):

{{ if eq .Title "Dummy Title" }}
{{ .File.BaseFileName | humanize | title }}
{{ end }}
3 Likes

This is genius!! Cascading the title works great. Where do I put the bit to use the filename?

You would need to enter it in the regular pages template.

Typically this template’s location is at:
/layouts/_default/single.html
OR
/layouts/<section-name>/single.html

Also have a look at Hugo’s Lookup Order for Regular Pages

Got it thank you, awesome :smiley:

1 Like

This topic was automatically closed after 38 hours. New replies are no longer allowed.