<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=172061883552505&amp;ev=PageView&amp;noscript=1">

How To Export a HubSpot Blog with the Content

Exporting a HubSpot Blog

Posted in HubSpot, and Blogging. 4 min read

If you've tried to use HubSpot's export blog posts feature, you already know that the exports do not contain any of your post content. This sucks! I needed this functionality recently to migrate a re-purposed HubSpot blog with over 1,000 posts into HubDBโ€”no way am I going to do this migration by copying and pasting each post by hand! ๐Ÿ˜ 

Well, fear not my fellow lazy employee trying to get out of copying and pasting posts for days on end... I've come up with a solution that requires minimal effort and will save you from losing your mind to monotony. Because of the simplicity of the CSV file syntax, it's not that hard to generate your own export from a coded HubSpot template.

 
 
 
 
 
3:01
 
 
 
3:01
 
 
 
 
 
 
 
 
 
 
Wistia video thumbnail - How To: Export a HubSpot Blog
 

Thanks for reporting a problem. We'll attach technical data about this session to help us figure out the issue. Which of these best describes the problem?

Any other details or context?

Cancel
message
 
 
 
 
 
 
 

 

Here's how to do it:

Step 1: Create a New Blog Template

In the Design Manager, create a new coded template titled "csv.html"

Screen Shot 2017-12-06 at 3.45.40 PM

Step 2: Copy and Paste

Remove all of the default code inside this new file. Then, copy and paste the following snippet:

{% if is_listing_view %}
"post_title","post_body","featured_image","author","topics",
{% for content in contents %}
"{{ content.name|forceescape|replace('
','') }}","{{ content.post_body|replace('"','""')|forceescape|replace('
','') }}","{{ content.featured_image|forceescape|replace('
','') }}","{{ content.author_name|forceescape|replace('
','') }}","{{ content.topic_list|forceescape|replace('
','') }}"{% endfor %}{% endif %}


What this does is loop through your posts, escapes the data, and removes line breaks from the content all while putting the data into a CSV formatโ€”the reason for the awkward formatting.

Your template should now look like this:

generate-csv-from-hubl.png

Step 3: Preview Page and Save

From this point, you should preview your blog listing by clicking on the "Open" link.

Screen Shot 2017-12-06 at 3.56.25 PM

 

And save the preview page to a file like so:

Screen Shot 2017-12-06 at 4.00.58 PM

Protip: to enable up to 1000 posts, change your "Number of Posts Per Listing Page" to 1000. You can find this setting under Content > Content Settings > Blog > Templates. Just don't forget to change this back when you're done as this will affect your main blog page load time.

Step 4: Save as a CSV

Open the file you just saved in your favorite text editor (Sublime Text is great) and remove the first and last line, as highlighted in my screenshots here:

remove-first-line.png

remove-last-line.png

Finally, save the file and change the file extension from .htm to .csv.

From this point, you can upload your CSV to Google Sheets and check that all the data is there and in order. Congratulations, you just made yourself a CSV containing all of your HubSpot blog post data!  ๐ŸŽ‰ ๐ŸŽ‰ ๐ŸŽ‰

New call-to-action

ร—
3d-Cover.png

Form Tilte Here