How to add <webfeeds:cover> to blog's Atom feed?

I’m trying to add the following entries to my blog’s atom feed:

<webfeeds:cover image="path/to/image.jpg" />
<webfeeds:icon>path/to/image.png</webfeeds:icon>
<webfeeds:logo>path/to/logo-30px-height.svg</webfeeds:logo>
<webfeeds:accentColor>67a43e</webfeeds:accentColor>
<webfeeds:related layout="card" target="browser"/> 

I’m using the Builder format to add the entries in this format:

xml.webfeeds:icon "path/to/image.png"

but I’m getting the following SyntaxError:

SyntaxError at /feed.xml
/Users/josh/Sites/site/source/feed.xml.builder:12: syntax error, unexpected tSTRING_BEG, expecting end xml.webfeeds:cover “image” => "https://site… ^ /Users/josh/Sites/site/source/feed.xml.builder:12: syntax error, unexpected =>, expecting end xml.webfeeds:cover “image” => "https://site.com/ima… ^~ /Users/josh/Sites/site/source/feed.xml.builder:29: syntax error, unexpected end, expecting end-of-input end;end;end;end ^~~

Any idea how to format the entries so Builder can generate the XML successfully?

Nevermind. I gave up trying to do it with Builder and rebuilt the feed with Nokogiri since there’s a lot more documentation.

For future searchers, I changed feed.xml.builder to feed.xml.nokogiri with the following content:

namespaces = {
  "xmlns" => "http://www.w3.org/2005/Atom",
  "xmlns:webfeeds" => "http://webfeeds.org/rss/1.0"
}

xml.feed(namespaces) do
  
  xml['webfeeds'].icon("path/to/image.png")
  xml['webfeeds'].logo("path/to/image.png")
  xml['webfeeds'].accentColor("FF0000")
  xml['webfeeds'].cover "image" => "path/to/image.png"
  xml['webfeeds'].related "layout" => "card", "target" => "browser"

  # Everything else...
end

I know it’s too late and I’m not sure if I solve exactly your problem, but if you have difficulty with the tags containing a colon, use this syntax in Builder:

    xml.tag! 'webfeeds:cover', image: "path/to/image.png"
1 Like

I still appreciate the help! Hopefully it will help the next person.