Get LastMod in Page with Shortcode

I am trying to implement a shortcode which injects the last modified date of a simple page into the page itself. Unfortunately there are two errors:

ERROR 2018/01/23 08:10:56 Shortcode 'lastmodified' in page 'my-page.md' has no .Inner, yet a closing tag was provided
ERROR 2018/01/23 08:10:56 error processing shortcode "shortcodes/lastmodified.html" for page "my-page.md": template: shortcodes/lastmodified.html:2:68: executing "shortcodes/lastmodified.html" at <$.Page.Params.lastmo...>: can't evaluate field format in type interface {}

Shortcode:

<meta itemprop="datePublished" content="{{ $.Page.Params.LastMod }}">
  {{ default (i18n "formatDate") .Site.Params.General.DateFormat | $.Page.Params.LastMod.Format | i18n "txtModifiedOn" }}
</meta>

Page:

---
title: "My Page"
url: "my-page"
lastmod: "2018-01-23"
---

{{% lastmodified %}}{{% / lastmodified %}}

LONG LONG TEXT ...

According to the hugo documentation, this should work but it does not.
What have to be edited?

You need to drop the closing shortcode, so:

{{% lastmodified %}}

Also note that the ‘%’ marks Markdown. In your case you would probably be better off with:

{{< lastmodified >}}

Thank you, the first error disappears. But I am not able to get the .Lastmod date, as you can see in the second error message.

Use

$.Page.LastMod …

Unfortunately, it does not work:

ERROR 2018/01/23 15:00:11 error processing shortcode "shortcodes/lastmodified.html" for page "my-page.md": template: shortcodes/lastmodified.html:1:44: executing "shortcodes/lastmodified.html" at <$.Page.LastMod>: can't evaluate field LastMod in type *hugolib.Page

$.Page.Lastmod …

Read the documentation carefully next time.