A custom hugo shortcode for interactive quizzes
A hugo shortcode for writing quizzes with a markdown-like syntax, called quizdown.
Quizdown is a javascript library which is developed in a separated project. hugo-quiz uses a simple shortcode to use quizdown with Hugo. For the library, you can either use a link to a CDN or download and link to the local quizdown.js
file.
demo/layouts/partials/custom-header.html
into your local layouts/partials/
folder. This inserts the nescessary javascript code inside the head
section of the hugo website.demo/layouts/shortcodes/quizdown.html
into your local layouts/shortcodes/
folder.--minify
flag of the hugo command causes issues with the raw quizdown-markdown code. Please remove the flag when building your website or use the following option in your config.toml
:[minify]
disableHTML = true
custom-header.html
)If your theme does not offer a custom-header.html
you need to add the library (and the extensions you want to use) to the head
section of your website:
<head>
...
<script
src="https://cdn.jsdelivr.net/npm/quizdown@latest/public/build/quizdown.js">
</script>
<script
src="https://cdn.jsdelivr.net/npm/quizdown@latest/public/build/extensions/quizdownKatex.js">
</script>
<script
src="https://cdn.jsdelivr.net/npm/quizdown@latest/public/build/extensions/quizdownHighlight.js">
</script>
<script>quizdown.register(quizdownHighlight).register(quizdownKatex).init()</script>
...
</head>
Write quizzes in plain markdown in any of your files in the content
directory:
# Hugo Quiz
{{< quizdown >}}
---
primary_color: orange
secondary_color: lightgray
text_color: black
shuffle_questions: false
---
## The sound of dog
---
shuffle_answers: false
---
What do dogs sound like?
> Some hint
- [ ] yes
- [ ] no
- [ ] `self.sound = "meow"`
- [x] wuff
## Put the [days](https://en.wikipedia.org/wiki/Day) in order!
> Monday is the *first* day of the week.
1. Monday
2. Tuesday
3. Wednesday
4. Friday
5. Saturday
{{< /quizdown >}}
The quizzes are for fun and not for serious assessment. Since everything is rendered on the client side, the hints and solutions to the questions become visible once javascript is disabled in the browser.
Check out the documentation on the main project page. You might be interested in:
Tested with version 0.80.0
of Hugo and the Hugo Learn theme.
Visit https://bonartm.github.io/hugo-quiz/ for a live demo based on the hugo-learn theme. You can also view a local version of the demo.
First download the theme:
git submodule update --init --recursive
Then start the server:
cd demo
hugo server -D