Skip to content

A library that utilizes HubSpot APIs for bulk updating COS content (Blog Posts and Site Pages)

Notifications You must be signed in to change notification settings

williamspiro/hub-batch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hub-Batch

A library that utilizes HubSpot APIs for bulk updating COS content (Blog Posts and Site Pages). Hub-Batch allows you to:

  1. Export post/page information from HubSpot to a CSV file
  2. Import post/page information to HubSpot from a CSV file
  3. Update and Publish live COS content
  4. Rollback changes 1 revision just in case
  5. Create new pages and posts
  6. Create, Delete, Update URL Mappings
  7. ...Run URLs through PSI

This tool has been used by HubSpot to bulk update content, with over 1000 pages updated at once.

hub-batch UI

Getting Started

Prerequisite

This tool requires node.js. You can install Node here.

Static IDs Setup

This tool allows you to quickly filter your get requests by blog groups, campaigns, topics, page name and/or URL slug. Since this information is unique to each HubSpot portal, you will need to populate the file js/static/staticids.js with your own IDs. Place any blog groups, campaigns or topics into that file, and they will automatically appear when using this tool.

Resources for finding each type of GUID:

To find a campaign GUID, click on the campaign in app and the GUID will appear in the page's URL

After you complete these two steps, you are ready to begin.

Usage

$ ./app.js

When you first run hub-batch in terminal, you will be asked to provide some authentication details. HubSpot’s APIs allow you to authenticate using a HapiKey or Access Token. You will automatically asked to be add a new token if the existing token expires.

Next, you’ll be asked to select a folder for Hub-Batch to be placed. This is the folder where CSVs will be exported and where you can add CSV files to be imported.

After this set up is complete, run $ hub-batch again to begin.

Example

From terminal, run:

$ ./app.js

Using the arrow keys, walk through the options provided:

hub-batch UI

After selecting your preferences, the CSV will be created: hub-batch sample IO

Documentation

This documentation covers the 4 main features: GET, UPDATE, PUBLISH, ROLLBACK

GET

Use this option to Get a CSV containing COS blog post/page data.

From terminal, run:

$ ./app.js

Using the arrow keys, select the following:

  • Content type: Blog Posts or Site Pages

For Blog Posts:

  • Operation type: GET
  • Which blog would you like to access?: This allows you to export content from a specific blog in your portal
  • Page State: Drafts, Published, Scheduled or All
  • Optionally refine further by:
    • Campaign
    • Topic
    • Name
    • Slug

For Site Pages:

  • Operation type: GET
  • Export drafts as well as live pages: Y/N
  • Optionally refine further by:
    • Campaign
    • Name
    • Slug

After selecting your options, hub-batch will create a CSV and place it in your exports folder. The resulting CSV will contain that following information by default for each page/post exported:

  • URL
  • Post Body
  • Meta Description
  • Name
  • ID
  • Slug
  • HubSpot Edit Link

And that's just the default. You can customize the tool to output whichever properties you'd like (even custom modules!). Once you have the CSV, open the file in Google Sheets (Excel mangles special characters) and make any changes you see fit to any of the properties. Find/Replace can be really handy. This has been very useful when rebrand or making any other bulk changes to live content.

UPDATE JSON, UPDATE BUFFER JSON, PUSH BUFFER JSON LIVE, PUBLISH ACTION

Use this option to Update the contents of COS blog post/page data. You will have the ability to select a CSV to import. An example import file can be found here.

From terminal, run:

$ ./app.js

Using the arrow keys, select the following:

  • Content type: Blog Posts or Site Pages
  • Which file would you like to import?: This will list any CSV file found in the Hub-Batch Imports folder.

After selecting the import file, Hub-Batch will begin updating each of the pages found in the CSV. NOTE make sure you understand the various options and ways of updating content

ROLLBACK

Use this option to Rollback published changes. This feature will revert any included pages 1 version.

From terminal, run:

$ ./app.js

Using the arrow keys, select the following options:

  • Content type: Blog Posts or Site Pages
  • Which file contains the content you'd like to rollback 1 version?: This will list any CSV file found in the Hub-Batch Imports folder.

POST OR PAGE CREATION

Use this option to Create Pages and Posts. This feature will create new post or page content objects

From terminal, run:

$ ./app.js

Using the arrow keys, select the following options:

  • Content type: Blog Posts or Site Pages
  • Which file contains the content you'd use to create pages or posts If you are creating posts, you must include a content_group_id in the request payload to ensure the post is created in the desired blog. If you are getting posts/pages from one portal, and creating them in another, do not forget to update the .env file with the destination portal authentication.

URL MAPPINGS CREATION, DELETION OR UPDATE

Use this option to Create, Delete or Update URL Mappings.

From terminal, run:

$ ./app.js

RUN URLS THROUGH PSI

Hit Googles https://www.googleapis.com/pagespeedonline/v4/runPagespeed api

From terminal, run:

$ ./app.js

Run with &strategy=mobile for mobile scores

About

A library that utilizes HubSpot APIs for bulk updating COS content (Blog Posts and Site Pages)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%