diff --git a/layouts/shortcodes/codefigure.html b/layouts/shortcodes/codefigure.html
index 3f768ad..9041474 100644
--- a/layouts/shortcodes/codefigure.html
+++ b/layouts/shortcodes/codefigure.html
@@ -1,5 +1,5 @@
{{- $codeIndex := (.Page.Scratch.Get "codeIndex") -}}
-{{- $id := (printf `code-%d` (sub $codeIndex 1)) -}}
+{{- $id := (printf `code-%d` $codeIndex) -}}
{{- with .Get "id" -}}
{{- $id = . -}}
{{- end -}}