HubSpot CMS is a powerful system for companies to manage both their website and content strategy. One of the most crucial aspects of HubSpot CMS is its use of Templates. Templates are files that define the layout of your HubSpot pages, emails, and themes. They are often the first thing selected when HubsSpot users create a new page or email. Due to their importance within HubSpot CMS, our SSIS Integration Toolkit for HubSpot has provided support for working specifically with Templates and their migration.
In this blog post, we will review two different scenarios for working with HubSpot Templates. The first scenario is transferring templates stored in your local machine to your HubSpot instance. This allows developers to develop their templates locally and then migrate them onto HubSpot afterward. The second scenario is migrating HubSpot templates from one HubSpot instance to another. A possible situation would be if you had a "master" template, but at the same time, you would need specific template changes for each department. In this case, we would want to push this "master" template(s) downstream from the main HubSpot instance to the other departments (with their own HubSpot instances) where they can make further changes.
Scenario 1: Migrating Templates from Local Folders to HubSpot
In this case, you can utilize a Premium File System Source component (available within our SSIS Productivity Pack) to read the template files and connect to the HubSpot Destination component, to then write to your HubSpot instance while performing some minor transformations (using a Premium Derived Column component, which will also allow you to provide any additional metadata needed for HubSpot).
The Premium File System Source component can be used to read from the New folder, which contains all the files we have on our local machine. Set the Advanced filter to pick up the template files based on any criteria depending on the file names present.
We would then use a Premium Derived Column component to create the additional columns needed for the HubSpot Destination.
In the NewSource column, we will use the function below to read the actual content from the file.
ReadTextContent( [__PremiumFilePack.FullPath] )
Next, we will need to specify the path where the file will be written in HubSpot. For this, we create a derived column called NewPath and concatenate the folder path with the file name.
"MigratedFolder/" + [__PremiumFilePack.Name]
The final derived column will be the Template Type, which is a numeric value that will set the type of template that is being created. Entering an invalid value or leaving it blank will set the template type to None. Below are the Template Types to choose from:
- 2 - Email template
- 4 - Page template
- 11 - Error template
- 12 - Subscription preferences template
- 13 - Backup unsubscribe page template
- 14 - Subscriptions update confirmation template
- 19 - Password prompt page template
- 27 - Search results template
- 29 - Membership login template
- 30 - Membership registration template
- 31 - Membership reset password confirmation template
- 32 - Membership reset password request template
Another optional field is the is_available_for_new_content field, which should be set to either True or False. By default, this field is set to False.
Now, in the HubSpot Destination component, you can choose the Destination Object as Template and set the action as Create.
Then, go to the Columns page, where you will map these columns to their respective fields.
With the above data flow configuration, you can easily migrate or create HubSpot templates from your local file system upon execution. You can see how simple the process is.
Alternatively, another solution for reading the templates involves using a flat file or Excel file that contains a table listing the template's source file path, template name, and new destination path. For example, if your templates are all listed in different folders, but you have a table listed where all the templates are, you could use this to create the necessary columns that are pushed to the Hubspot destination component.
In this example, it's in an Excel file, so you can use a Premium Excel Source component. However, you can use any Source component depending on the data source. With this method, you can read files from different folders, and with the IfElse function in the Premium Derived Column component, you can easily convert the Template Type to the value needed.
Scenario 2: Migrating Templates from HubSpot to HubSpot
In this case, you will need a HubSpot Source and HubSpot Destination component connected to 2 different HubSpot Connection Managers, each connecting to a different HubSpot instance. In between the Source and the Destination components, you will include a Premium Derived Column component, which will be used to provide additional columns required for the transformation.
The Source component will be used to read the template. In the component, set the Source object as Template.
With our Source component, you can further filter to read specific templates by using the Filter Parameters. This way, you have greater control over which templates you wish to migrate. For example, if you want to migrate a "master" template to other HubSpot instances, you may set the is_availabe_for_new_content value to True. By using filters, templates migrated can be further edited and tailored for different situations. In the Premium Derived Column component, you can set up the new path to which you are writing. You will need to set this as the path from your Destination HubSpot instance, as this may be different from the Source, and may not transfer properly without the path.
Finally, you will map the Premium Derived Column component to the HubSpot Destination component that is connected to the second HubSpot instance. The steps are similar to the first scenario, where you create the templates with the Template chosen as the Destination Object. In the columns tab, you can map the fields you are getting from your Source component to the Destination.
Conclusion
In this blog post, we have gone over HubSpot Templates in SSIS and the different scenarios for migrating HubSpot templates, whether from a local environment to HubSpot, or from HubSpot to HubSpot. This approach simplifies the design complexity for migration cases, allowing you to handle and process templates with greater flexibility and efficiency.
We hope this has helped!