Create a component that is reusable across your pages and templates called a custom module. You will learn about fields, and using them with HubL.
npm install @hubspot/cli
.~/.hscli/config.yml
file was created.
my-theme
. A theme folder named my-theme
will then be created in your working directory containing the boilerplate assets.Parameter | Description |
---|---|
The path to your local files, relative to your current working directory. | |
The destination path in your HubSpot account. This can be a new folder. |
hs upload my-theme my-new-theme
would upload the my-theme
folder from your machine to a my-new-theme
folder in HubSpot
hubspot.config,yml
file. However, you can also specify an account by including a --account=<accountNameOrId>
flag in the command. For example, hs upload --portal=mainProd
.Learn more in the CLI command reference.module.html
section.
module.html
to display the field data.
module.html
pane:
module
, followed by the field’s HubL variable name. You can use dot notation to further access specific properties of a field, which you can see in the profile_pic
tokens on line 3 above.
hs fetch <hs_src> <destination>
:
<hs_src>
represents the module’s filepath in HubSpot. To get the filepath, you can right-click the module in the left sidebar of the design manager, then select Copy path.<destination>
represents the path to the local directory where your theme lives. If omitted, the command will default to the current working directory.Parameter | Description |
---|---|
fields.json | A JSON object that contains your module’s fields. |
meta.json | A JSON object that contains meta information about your module. |
module.css | The CSS file that styles your module. |
module.html | The HTML and HubL for your module. |
module.js | The JavaScript for your module. |
fields.json
and meta.json
files. In this tutorial, we’ll focus on the fields.json
, module.css
, and module.html
files and how they are generated by, downloaded from, and uploaded to the module editor in the Design Manager.
fields.json
file. Aside from some of the id
numbers, the src
attribute of the image field, and potentially the order of fields, the file should contain a JSON object similar to the following:
name
: the name of the field.label
: the field’s label.default
: the field’s default value.module.html
file should contain the HubL and HTML that you wrote in the HubL + HTML module editor previously.
To make this code more interesting and ready for CSS styling, copy and paste the following code into the file:
module.css
file should be empty at this point. To add styling, copy and paste the following code into the file:
hs watch <src> <destination>
.module.html
and module.css
panes.modules
and templates
folders within your local theme files.
templates
folder, then open the home.html
file.home.html
file, navigate to the final dnd_section
, which starts around line 28. You’ll be adding your new module to this section.dnd_section
and above the other dnd_modules
, copy and paste the following HubL module tag:dnd_section
, it also assigns a module width
and offset
:
dnd_section
to have a width of 4
.dnd_module
in the group (testimonial
) will have an offset of 0
to position it first.dnd_module
(linked_image
) will have an offset of 4
to position it second.dnd_module
(rich_text
) will have an offset of 8
to position it third.offset
and width
of each dnd_module
, your code will look similar to the following:
{% module "testimonial_one" path="../modules/Testimonial.module" %}
Learn more about using modules in templates.watch
command running to track your saved work automatically, run hs watch <src> <dest>
. Ensure that this command keeps running as you complete the next steps.home.html
file.customer_name
: this parameter passes the name Mary
to the customer name field, overriding the original value of Sally
.profile_pic
: this parameter is an object that contains two properties:
src
property uses the get_asset_url
HubL function to retrieve the URL for the new profile picture. Note that the image’s file path is relative to your working directory. You’ll first need to add this image to the images
folder in your local theme files. You can find the image in the images
folder of the completed project files.alt
property assigns the image’s alt text.testimonial
: this parameter passes new text into the testimonial field.watch
command running in your terminal, saving your changes will send them to HubSpot. You can then navigate back to the design manager to preview the template.
home.html
file.
Ollie
.I can't believe that I ever conducted business without the use of this product!
images
folder. You can get the image itself from the finished project files. Then give Ollie’s image the alt
attribute of Ollie Profile Picture
.offset
to 4
and width
to 4
.Erin
.My business has nearly tripled since I began to use this product! Don't wait, start now!
images
folder. Then give Erin’s image the alt
attribute of Erin Profile Picture
.offset
to 8
and width
to 4
.watch
command running in your terminal, you can navigate back to the Design Manager to preview your changes to the template. The template preview should now contain all three testimonial modules.
theme.json
file.
name
and label
fields in the theme.json
file.
watch
command sends your changes to HubSpot.
home.html
template, and optionally customized the theme name, you’re ready to create a live page from the theme.
If you’d like to follow a similar tutorial that focuses on themes, check out the Getting started with themes tutorial next. Otherwise, you can learn more about creating and customizing pages in HubSpot’s Knowledge Base.
Or, if you’d like to learn more about modules, check out the following module guides: