️ Create rich HTML-based presentations with Hugo and Reveal.js
️ Create rich HTML-based presentations with Hugo and Reveal.js
A Hugo theme for Reveal.js that makes authoring and customization a breeze. With it, you can turn any properly-formatted Hugo content into a HTML presentation.
⚠️ The latest version of this theme requires hugo version >= v0.93.0. If you need compatibility with an earlier version, try a previous release.
Using reveal-hugo, presentations with multiple slides can be created with just one markdown file, like so:
+++
title = "How to say hello"
+++
# English
Hello.
---
# Français
Salut.
---
# Español
Hola.Just use --- surrounded by blank lines to split content into different slides.
Visit reveal-hugo.dzello.com to see a presentation created with this theme and learn about all of the different functionality available to you.
For a full-length blog post about reveal-hugo, checkout Harness the Power of Static Site Generators to Create Presentations on the Forestry.io blog.
Jump to the exampleSite folder in this repository to see the source code for the above presentation and several more. Here are links to those presentations live:
If you want to start creating a presentation right away, clone the programming-quotes repository and start hacking.
You should be able to complete this section with no prior knowledge of Hugo or Reveal.js. At the end, you'll have a working presentation with instant reloading.
To start, install Hugo and create a new Hugo site:
hugo new site my-presentationChange into the directory of the new site:
cd my-presentationInitialize a git repository:
git initreveal-hugo themeTurn your new skeleton site into a hugo module by issuing this command from site root:
hugo mod init github.com/me/my-presentationreveal-hugo theme module as a dependency of your site:hugo mod get github.com/joshed-io/reveal-hugoOpen hugo.toml and add the following line:
theme = ["github.com/joshed-io/reveal-hugo"]Add the reveal-hugo theme as a submodule in the themes directory:
git submodule add [email protected]:joshed-io/reveal-hugo.git themes/reveal-hugoOpen hugo.toml and add the following line:
theme = ["reveal-hugo"]Add some more contents to your hugo.toml:
[markup.goldmark.renderer]
unsafe = true
[outputFormats.Reveal]
baseName = "index"
mediaType = "text/html"
isHTML = trueThis tells Hugo to use the reveal-hugo theme and it registers a new output format called "Reveal".
Next, create a file in content/_index.md and add the following:
+++
title = "My presentation"
outputs = ["Reveal"]
+++
# Hello world!
This is my first slide.Back on the command line, run:
$ hugo serverNavigate to http://localhost:1313/ and you should see your presentation.
To add more slides, just add content to _index.md or create new markdown files in content/home. Remember that each slide must be separated by --- with blank lines above and below.
# Hello world!
This is my first slide.
---
# Hello Mars!
This is my second slide.If you have an existing repository that was setup with the above steps, you have to pull in the theme submodule after cloning your repository using the following command:
git submodule update --initWhen making use of reveal-hugo theme as hugo module, updating your theme is really easy:
At the command prompt, change to the root directory of your existing site.
cd /path/to/my-presentationThen invoke hugo's module get subcommand with the update flag -u:
hugo mod get -u github.com/joshed-io/reveal-hugoHugo will automatically pull in the latest theme version. That's it, your update is done!
The Usage guide is contained in the example presentation that lives in this repository in the exampleSite directory. You can access a live version at reveal-hugo.dzello.com.
Here's what the folder structure would look like with one root presentation and one section presentation.
- content
- home # special section for appending to root presentation
- body.md # appends to the root presentation
- conclusion.md # appends to the root presentation
- _index.md # beginning of the root presentation
- ted-talk
- _index.md # beginning of the ted talk presentation
- body.md # appends to the ted talk presentation
- conclusion.md # appends to the ted talk presentationThis will create two presentations, one at / and one at /ted-talk/. The order that slides are appended to each can be controlled by the weight parameter specified in each file's front matter. The slides in _index.md will always come first, though you don't have to put any slides in there if you want to.
reveal-hugo comes with a variety of shortcodes that help you take advantage of some very useful Reveal.js features.
Wrap any content in the fragment shortcode and it will appear incrementally. Great for bulleted lists where you want one bullet point at a a time to appear.
- {{% fragment %}}One{{% /fragment %}}
- {{% fragment %}}Two{{% /fragment %}}
- {{% fragment %}}Three{{% /fragment %}}Like fragment but more terse - content is placed inline in a self-closing shortcode.
- {{}}
- {{}}
- {{}}The slide shortcode lets you set custom HTML and Reveal.js attributes for each slide - things like id, class, transition, background just to name a few. The names are the same as Reveal.js but without the 'data-' prefix.
Add the shortcode above the slide content, below the --- separator. Do not place content inside of the shortcode.
---
{{}}
# Hello, world!
---Here's a list of documented slide attributes from the Reveal.js docs:
autoslidestatebackgroundbackground-colorbackground-imagebackground-sizebackground-positionbackground-repeatbackground-opacity (Opacity is on a 0-1 scale, by decimal. 0=transparent, 1=opaque.)background-videobackground-video-loopbackground-video-mutedbackground-interactivebackground-iframebackground-transitiontransition (can have different in and out transitions)transition-speednotes (can also use the note shortcode)timingCheck MDN for information about how these attributes work.
You can also pass through your own, a data- prefix will be added automatically to each one (except for id and class).
To create groups of slides that can be navigated vertically, surround your markdown with the section shortcode.
{{% section %}}
# Vertical slide 1
---
# Vertical slide 2
{{% /section %}}Add speaker notes for each slide with the note shortcode.
{{% note %}}
Don't forget to thank the audience.
{{% /note %}}note attribute to the slide shortcode.*Markdown surrounded by the markdown shortcode will not be rendered by Hugo but by Reveal.js itself. This is useful if you want to use some native Reveal.js markdown syntax that isn't supported by reveal-hugo.
{{% markdown %}}
# I'm rendered...
...by Reveal.js
{{% /markdown %}}MathJax)math code blockYou can author your equation inside a math code block:
```math
\tag*{(1)} P(E) = {n \choose k} p^k (1-p)^{n-k}
```Use of the code block will automatically activate needed MathJax script for equation display.
If you want to use inline equations (like $E=mc^2$) wrap your math content in two single-$:
Albert Einstein's famous formula: $E=mc^2$If you want to use inline equations and no math code block for auto activation is present in your slides, you need to manually enable MathJax by setting the parameter math to true in your page frontmatter.
math shortcodeAlternatively, you can author your equation inside a math shortcode:
{{}}
\tag*{(1)} \frac{n!}{k!(n-k)!} = \binom{n}{k}
{{}}Use of the shortcode will automatically activate needed MathJax script for equation display.
For inline equations (like $E=mc^2$) use the self closing form of the math shortcode:
Albert Einstein's famous formula: {{}}For the sake of brevity, the inline content can be given as unnamed first shortcode parameter, as in the code fragment above. In a more concise form, the math content can also be assigned to a named shortcode parameter inline: {{}}.
If you need to create fancier HTML for a slide than you can do with markdown, just add data-noprocess to the <section> element.
Hello, world!
Sometimes you need to reuse a slide in the same presentation or across different presentations. reveal-hugo makes use of Hugo data templates to make both cases easy.
To create reusable slides, create a TOML (or JSON or YAML) file in your site's data directory. Give it a name that reflects its content or just slides.toml. In that file, add a key for each reusable slide. The name should reflect the slide's content and the value should be the slide's markdown.
thankyou = '''
# Thank you!
Any questions?
'''No open issues yet, or sync has not completed.