Feed RSS en Hugo

Como crear un feed para podcast con HUGO

Validators / Validadores

Namespaces

  • Soportados por AntennaPod:
    • RSS2: channel item guid title link description pubDate enclosure {url,length,type} image {url} language
    • atom: … link {href,rel,type,title,length} …
    • content: encoded -> Para contenido con HTML si “description” no es más largo
    • itunes: image {href} author duration subtitle summary new-feed-url
    • podcast : funding chapters : https://podcastindex.org/namespace/1.0
    • dc: date
    • media: content url fileSize type duration isDefault medium {image,audio,video} thumbnail {url} description {type} : http://search.yahoo.com/mrss/
    • simple-chapters: chapters {chapter} {start,title,href,image} : http://podlove.org/simple-chapters

En uso

Sin uso

Docu

Hugo

Generador con hugo

Contenido escondido en la pestaña RSS para ahorrar espacio. Tambien revisable aquí

{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
    xmlns:podcast="https://podcastindex.org/namespace/1.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
>
<channel>
    <title>{{ with .Title }}{{.}}{{ end }}</title>
    <link>{{ .Permalink }}</link>
    {{ with .Description }}
    <description>{{.}}</description> {{ end }}
    <generator>https://gitlab.com/Marzal/hugo-cards-podcast</generator>
    {{ with .Site.LanguageCode }}<language>{{.}}</language>{{ end }}
    {{ if not .Date.IsZero }}
    <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 +0000" | safeHTML }}</lastBuildDate> {{ end }}
    {{ with .OutputFormats.Get "RSS" }}
        {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} {{ end }}
    {{ with .Site.Author.email }}
        <managingEditor>{{.}} {{ with $.Site.Author.name }}({{.}}){{ end }}</managingEditor>
        <webMaster>{{.}}{{ with $.Site.Params.builtBy }} ({{.}}) {{- else }} ({{ $.Site.Author.name}}){{ end }}</webMaster>
    {{ end }}
    {{ with .Site.Author.name }}
    <copyright>{{.}} {{ now.Format "2006" }}</copyright> {{ end }}
    {{ if .Site.Params.copyright.license }}
    <podcast:license {{ with .Site.Params.copyright.licenseURL }}url="{{.}}"{{ end }}>({{.Site.Params.copyright.license}})</podcast:license>
    {{ end }}
    {{ with .Params.p20.guid }}
    <podcast:guid>{{.}}</podcast:guid>{{ end }}
    {{ if .Param "p20.fundingURL" }}
    <podcast:funding {{ with .Param "p20.fundingURL" }}url="{{.}}"{{ end }}>{{ .Param "p20.funding" }}</podcast:funding>
    {{ end }}
    <podcast:locked {{ with .Site.Author.email }}owner="{{.}}"{{ end }}>{{ with .Param "p20.locked" -}}{{.}}{{- else -}} no {{- end }}</podcast:locked>
    {{ if .Param "p20.location" }}
    <podcast:location 
    {{ with .Param "p20.locationGEO" }}geo="geo:{{.}}"{{ end }}
    {{ with .Param "p20.locationOSM" }}osm="{{.}}"{{ end }}
    >{{.Param "p20.location"}}</podcast:location>
    {{ end }}
    <image>
        <url>{{ .CurrentSection.Permalink }}{{ .Params.podcast_image}}</url>
        {{ with .Title }}<title>{{.}}</title>{{ end }}
        <link>{{ .Permalink }}</link>
    </image>
    <itunes:explicit>{{ with .Param "itunes.explicit" -}}{{.}}{{- else -}} false {{- end }}</itunes:explicit>
    <itunes:category text="Technology" />
    <itunes:category text="News">
        <itunes:category text="Tech News" />
    </itunes:category>
    <itunes:image href="{{ .CurrentSection.Permalink }}{{ .Params.podcast_image}}" />
    {{ with .Site.Author.name }}
        <itunes:author>{{.}}</itunes:author>
        <itunes:owner>
            <itunes:name>{{.}}</itunes:name> {{ end }}
    {{ with .Site.Author.email }}<itunes:email>{{.}}</itunes:email>
        </itunes:owner>
    {{ end }}
    {{ range $i, $pg := .Pages }}
    <item>
        <title>{{ $pg.Params.title }}</title>
        <link>{{ .Permalink }}</link>
        <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 GMT" | safeHTML }}</pubDate>
        <guid isPermaLink="false">{{ $pg.Params.title }}</guid> 
            {{ with .Params.podcast.mp3 }}
                {{ $file_stat := os.Stat (add "/static/images/" (. | relURL)) }}<enclosure url="{{ . | absURL }}" length="{{ $file_stat.Size }}" type="image/png" />
            {{ end }}
        {{ if .Params.podcast.audio }}
        <enclosure url="{{.Params.podcast.audio}}.ogg" length="{{ with .Params.podcast.olength -}} {{.}} {{- else -}} 0 {{- end }}" type="audio/ogg" />
        <enclosure url="{{.Params.podcast.audio}}.mp3" length="{{ with .Params.podcast.mlength -}} {{.}} {{- else -}} 0 {{- end }}" type="audio/mpeg" />
            {{ with .Params.podcast.iduration }}
        <itunes:duration>{{.}}</itunes:duration>
            {{ end }}
        {{ end }}
        {{ printf "<description><![CDATA[%s]]></description>" .Summary | safeHTML }}
        {{ printf "<content:encoded><![CDATA[%s]]></content:encoded>" .Content | safeHTML }}
        {{ with .Site.Author.email }}
            <author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{ end }}</author>
        {{ end }}
        <itunes:explicit>{{ with .Param "itunes.explicit" -}}{{.}}{{- else -}} false {{- end }}</itunes:explicit>
        <itunes:image href="{{.Site.BaseURL}}images/{{.Params.img}}"></itunes:image>
        {{ with .Site.Author.name }}<itunes:author>{{.}}</itunes:author>{{ end }}
        {{ if and (.CurrentSection.Params.p20.protocol) (.Params.podcast.siuri) }}
        <podcast:socialInteract
            uri="{{ .Params.podcast.siuri }}"
            protocol="{{ .CurrentSection.Params.p20.protocol }}"
            {{ with .CurrentSection.Params.p20.accountId }}accountId="{{.}}"{{ end }}
            {{ with .CurrentSection.Params.p20.accountUrl }}accountUrl="{{.}}"{{ end }}
        /> {{ end }}
        {{ if and (.Params.podcast.trurl) (.Param "p20.trtype") }}
        <podcast:transcript url="{{ .Params.podcast.trurl }}" type="{{ .Param "p20.trtype" }}"
        />{{ end }}
        {{ if .Params.podcast.location }}
        <podcast:location 
        {{ with .Params.podcast.locationGEO }}geo="geo:{{.}}"{{ end }}
        {{ with .Params.podcast.locationOSM }}osm="{{.}}"{{ end }}
        >{{.Params.podcast.location}}</podcast:location>
        {{ end }}

    </item>
    {{ end }}
</channel>
</rss>
  

Duración del audio

    <enclosure url="{{ $pg.Params.link }}" type="audio/mpeg" length="0" />
  • Sacandolo del Params
    {{ $audio_name_arr := split (index .Params.audio 0) "." }}
    {{ $audio_type := index $audio_name_arr (sub (len $audio_name_arr) 1) }}
    {{ $audio_size := 0 }}
    {{- if .Params.audio_size }}{{ $audio_size = int .Params.audio_size }} {{ end -}}
    <enclosure url="{{ index .Params.audio 0 | absURL }}" length="{{ $audio_size }}" type="audio/{{ $audio_type }}" />
    <enclosure url="{{ .Site.Params.media_prefix }}{{ .Params.podcast_file }}" {{with .Params.podcast_bytes}}length="{{ . }}"{{ end }} type="audio/mpeg" />

Ejemplos

Foros


Última modificación March 10, 2024: pruebas llava con logo ATL (76557a9)