CMS Development

mw_corelight
Member

Modify the rss feed for our blog

SOLVE

We have a request to configure our HubSpot RSS feed to include the complete blog post and not just the summaries so that users can read the blog in feed readers like Feedly. Are there any resources for doing this? Thanks.

0 Upvotes
1 Accepted solution
Phil_Vallender
Solution
Most Valuable Member | Diamond Partner
Most Valuable Member | Diamond Partner

Modify the rss feed for our blog

SOLVE

Hi @mw_corelight 

 

To the best of my knowledge it is not possible to modify the contents of the default HubSpot RSS feeds.

 

The solution is probably to build your own RSS feed using the blog API and, potentially, the Serverless Functions feature of CMS enterprise - if you have it. 

 

Hope this helps.

Phil Vallender | HubSpot Website Agency

View solution in original post

3 Replies 3
Phil_Vallender
Solution
Most Valuable Member | Diamond Partner
Most Valuable Member | Diamond Partner

Modify the rss feed for our blog

SOLVE

Hi @mw_corelight 

 

To the best of my knowledge it is not possible to modify the contents of the default HubSpot RSS feeds.

 

The solution is probably to build your own RSS feed using the blog API and, potentially, the Serverless Functions feature of CMS enterprise - if you have it. 

 

Hope this helps.

Phil Vallender | HubSpot Website Agency
mw_corelight
Member

Modify the rss feed for our blog

SOLVE

Thanks for the information. We can leverage the Serverless Function feature so it would be great if there was a resource for how the API and this feature can interact to create a custom RSS feed.

0 Upvotes
blend-thomas
Contributor | Diamond Partner
Contributor | Diamond Partner

Modify the rss feed for our blog

SOLVE

It's usually a case of throwing together a bunch of resources from HubSpot to get the result you require.

 

As @Phil_Vallender mentioned, we've looked at using Serverless Functions to bounce data from the API and output to the browser.

 

This example is taking data from HubDB, but you could swap that out for Blog post data;

 

https://developers.hubspot.com/docs/api/cms/blog-post

 

const axios = require('axios');
exports.main = (context, sendResponse) => {

  const endpoint = `https://api.hubapi.com/cms/v3/hubdb/tables/articles/rows?hapikey=${process.env.hsapi}`

  getArticles = async function getArticles() {

    const resp = await axios.get(endpoint);
    const data = resp.data;

    let xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"+
                  "<rss version=\"2.0\">\n";

    Object.entries(data.results).forEach(function ([key, value]) {
        xml += "<item>\n";
        xml += "<pubDate>"+value.createdAt+"</pubDate>\n";
        Object.entries(value.values).forEach(function ([key, value]) {
          if(key=='title') {
            xml += "<title>"+value+"</title>\n";
          }
          if(key=='body') {
            xml += "<description>"+value+"</description>\n";
          }
          
          
          // xml += "<description>Here is some text containing an interesting description.</description>\n";
          // xml += "<link>http://www.example.com/blog/post/1</link>\n";
          // xml += "<pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate>\n";
        })
        xml += "</item>\n";
      });
    
    xml += "</rss>";
    //console.log(xml);
    
    try {
      sendResponse({
        body: xml, statusCode: 200, headers: {
          "Content-Type": "text/xml"
        }
      });
    } catch (err) {
      return err;
    }
  }
  getArticles();
};

.