Add a static oEmbed endpoint to your hugo website by generating a oEmbed file for each of your posts.
Currently supported oEmbed content types:
-
link
Add the theme component as submodule to your hugo prject:
git submodule add https://github.com/devidw/hugo-theme-component-oembed.git ./themes/hugo-theme-component-oembed
Specify the output format in your config.yaml
file:
outputFormats:
# hugo-theme-component-oembed
oembed:
name: "oembed"
baseName: "oembed"
mediaType: "application/json"
isPlainText: true
Also add the output format to the outputs
array:
outputs:
home:
# …
- OEMBED # hugo-theme-component-oembed
page:
# …
- OEMBED # hugo-theme-component-oembed
Include the oembed.html
partial in the <head>
of you themes template file, for example baseof.html
:
{{/* hugo-theme-component-oembed */}}
{{ partial "oembed.html" . }}
This will create a link like the following on page build:
<link rel="alternate"
type="application/json+oembed"
href="https://example.com/oembed.json">