Include slides from other files
Many speakers use the same slides in every talk: an “about me” slide, an agenda template, sponsor slides or a “thank you” slide. Instead of copying them into every slide file, keep them in a markdown file of their own and include that file with the src property:
---theme: frost---
# My talk
---src: ../shared/about-me.md---
---
# Let's get startedThe slide with src is replaced by all the slides of about-me.md. When you update about-me.md, every talk that includes it shows the new version. The src property uses the same syntax as Slidev.
Paths
- A path is relative to the file with the
src:../shared/about-me.mdor./agenda.md. - A path that starts with
/is relative to the workspace folder:/.demo/shared/about-me.md. - Only files in the workspace folder can be included.
An included file can include other files too. Its paths are relative to the included file.
Front matter
The included slides keep their own front matter, including the document front matter of the included file. The document front matter of the file that includes them applies on top of it, with the usual rules:
themeandcustomThemeof the including file win, so the included slides look like the rest of your deck.transition,header,footer,background,classand the other properties only apply to the included slides that don’t set their own value.
The other properties next to src apply to every included slide. This hides all the slides of the sponsor file in this talk:
---src: ../shared/sponsors.mdhide: true---The content of a slide with src is not shown, as the slide is replaced by the included slides.
Slide numbers, the navigator and the export
The included slides are part of the deck, the same as slides of the file itself:
- Slide numbers,
{{crntSlideIdx}}and{{totalSlides}}in the header and footer, and the progress bar count them. - The
slideproperty of theopenSlidemove counts them. - The slide navigator, the slide thumbnails, the next slide in the presenter view, and the PDF export show them.
Edit included slides
The slide preview loads the slides again when you save an included file.
- Show slide contents and a double-click on the slide open the included file at the slide.
- When the cursor moves to a slide in the editor of an included file, the preview shows that slide when the file is part of the deck.
- The speaker notes pane saves the notes in the included file.
- In the slide thumbnails, included slides have a link icon, and their tooltip shows the file they come from.
- The slide context menu of an included slide only has Show slide contents, as the other actions would change the slides of every talk that includes the file. Included slides can’t be dragged in the slide thumbnails. Drag a slide of the file onto them to move it before or after all of them.