# Gallery Shortcode
I'm using the following shortcode (saved as `gallery.html`) in Hugo to generate a gallery containing
both video and photos. Comments in the code.
May it be helpful for you. It comes (of course) with no support. The cover photo handling is done by
my Hugo theme (terminal) btw.
~~~ go-tmpl
{{- $videos := .Page.Resources.Match "img/*.webm" -}}
{{- $videos = $videos | append ( .Page.Resources.Match "img/*.ogv" ) -}}
{{- range $videos -}}
{{- $caption := "" -}}
{{- $captionfile := printf "%s.%s" ( strings.TrimSuffix (path.Ext .RelPermalink) .RelPermalink ) "txt" -}}
{{- if os.FileExists $captionfile -}}
{{ $caption = os.ReadFile $captionfile | markdownify -}}
{{- end -}}
{{- $type := printf "%s/%s" "video" (slicestr (path.Ext .RelPermalink) 1) -}}
{{- $type = replace $type "ogv" "ogg" -}}
{{ $caption }}