Learn how to migrate a HubL theme to the projects framework to build with React.
Restructure your theme
hsproject.json
configuration file. This file configures the project itself. Paste the following code into the project. You can use any name
value you’d like.
src
directory, which will contain your theme files. This directory can have any name, but will need to match the srcDir
value defined in the hsproject.json
file.
src
directory.
package.json
file to include the required dependencies: @hubspot/cms-components
and @hubspot/cms-dev-server
. You can use the example code below to get started:
components
directory, then add a modules
directory within it (src/theme/components/modules
). This directory will contain your theme’s React modules. If your existing HubL modules are contained in a modules
directory, you’ll need to rename that directory (e.g., hubl-modules
), because modules
is reserved for React modules within the projects framework.
package.json
files:package.json
is optional, but it’s where you can install
certain development dependencies that may be helpful during local
development (e.g., prettier, eslint).package.json
is required, as developing React modules
requires the @hubspot/cms-components
and @hubspot/cms-dev-server
dependencies.Add a React module
src/components/modules
directory, create a PlaceholderModule
directory, then add an index.jsx
file containing the following code:Update HubL file extensions
.hubl
in the file extension.module.html
becomes module.hubl.html
template.html
becomes template.hubl.html
partial.html
becomes partial.hubl.html
module.css
becomes module.hubl.css
module.js
becomes module.hubl.js
hubl.css
:{% include './elements/buttons.css' %}
{% include './elements/buttons.hubl.css' %}
.hubl.html
template, existing page content will not be impacted (i.e., live website content will stay the same). However, if you want to update that content in the editor, you’ll need to manually rebuild it by adding the new module to the page and recreating the content.Deploy your project to HubSpot
hs project upload
. This command will build and deploy both your HubL and React assets, so you’ll no longer need to use hs upload
. If you would like to watch for changes, you can use the project-specific watch command: hs project watch
. However, this is less necessary when working with CMS React because you can view your local changes to both HubL and React assets without requiring a deploy to your account.