Data written in markdown

Hi there

I’m new to HUGO, and also quit new to Web Development aswell. I was always more on the DevOps/Backend side of things.

What I’m trying to do

I’m trying to create a Hugo website that will be hosting a Quiz that would help others in preparation for an exam.

The code repository is GitHub - FidelusAleksander/github-actions-quiz

The issue

For the hugo-quiz to work, all the questions have to be written in Markdown and use the quizdown shortcode in the content page, like this

I’d like to externalize the markdown questions to separate .md files, maybe group them by subjects in the exam or keep it 1 file = 1 question (haven’t decided, but keeping all questions in 1 content file is not something I want to go with).

How should I approach this? I’ve seen that data files cannot be in markdown format

Thanks in advance

I see this as two content types.

├── questions/
│   ├──
│   ├──
│   └──
└── quizzes/

In the example below, subject and level are taxonomies:

title = 'Question 1'
date = 2023-08-18T07:14:12-07:00
draft = false
subject = ['caches']
level = ['easy']
answer = 2

Which of the following is true?

1. xxx
2. yyy
3. zzz

Then create a quiz template that builds a page collection based on whatever, then range through the questions. No shortcodes.

The front matter in each can be used to control the page collection:

title = 'Quiz 1'
date = 2023-08-18T07:14:12-07:00
draft = false
include_subjects = ['caches','performance','security']
include_levels = ['easy']
number_of_questions = 42
shuffle = true
1 Like

I see, I should think of the questions as content not as “data”. Thanks for the tip

Ranging through the questions should be done in some layout for the quiz, is that correct?

I can’t seem to find a way to actually render the Contents properly when ranging through the pages. I’ve prepared a PR with a screenshot


The context within each iteration of the outer loop is “question” page. Remove the inner loop.

Simple example:

git clone --single-branch -b hugo-forum-topic-45786 hugo-forum-topic-45786
cd hugo-forum-topic-45786
hugo server

I’ve cloned the branch and it fails to start-up

Error: Unable to locate config file or config directory. Perhaps you need to create a new site.
       Run `hugo help new` for details.

Even though the hugo.toml file is in my current working directory

bash: ls

archetypes assets content hugo.toml layouts LICENSE resources static

What’s your Hugo version? Run hugo env command.

I just installed it few days ago using the guide from the Hugo site so I’d assume latest

hugo env

Hugo Static Site Generator v0.68.3/extended linux/amd64 BuildDate: 2020-03-25T06:15:45Z

That guide recommends Hugo version 112 or later. Your version is very old. You need to upgrade your Hugo version.

Wow that’s surprising :smiley: I’d think that using the installation guide would get me the latest version

I’ve installed directly from the .deb package from Github releases and the branch from @jmooring works :slight_smile:
I’ll take some time to understand it and apply it to my use-case

Thanks everyone

I need to get the raw uninterpreted content, for the

<div class='quizdown'>
 {{ .Content }}

to work properly, but the .Content in the div seems to already be HTML not Markdown, is there a way to change this behaviour?


Omg it works

I’ve tried looping os.ReadDir and os.ReadFile but failed, this is much simpler

Thanks a ton @jmooring !