Template variables
blog_page_path
blog_page_path
Note: Only available within blog templates currently.
Get the page path of the blog root page. Example if you have a blog under https://www.example.com/locations/seattle/blog/
the blog_page_path
would be /blog/
blog_root
blog_root
Note: Only available within blog templates currently.
Get the URL of the blog root page. Includes the base_directory
. Example if you have a blog under https://www.example.com/locations/seattle/blog/
the blog_root
would be /locations/seattle/blog/
filter_posts
filter_posts
Get blog posts for the current site based on a supplied category slug. Note: Only available within blog templates currently.
If accessing posts outside blog templates, use get_posts
get_categories
get_categories
Get list of all the current blog categories and links. Note: Only available within blog templates currently.
Other available category values
Value | Description |
---|---|
| Total number of posts in that category (i.e |
| Slug of the category (i.e. |
get_image
get_image
Utility for getting additional image details from an image ID
Initialize the image using the ID of the image.
If an image is coming from custom_fields
, you can access the ID value from an image using the field_name_id
if the normal image path would have been field_name
Get an image path by size
This will return the full path the image that you can use in CSS or image tags/img/upload/image-name-here.thumbnail.jpg
For a list of available sizes, see:
Images and videoget_menu
get_menu
Load a website menu to use for rendering the menu as a navigation
Generating a menu tree
The menu from get_menu
can be iterated over recursively to output a nested ul
or other element for a navigation
Additional options
root_link
option
root_link
optionThis option allows you to filter/search and generate a partial menu for a item with link matching the root_link
This can be used to grab part of a menu to use in a sidebar or other places without the need to create a separate menu within the template.
Note: the item.depth
will still reflect the original depth within the entire menu.
get_posts
get_posts
Get recent blog posts throughout Site pages.
Simple usage
Limiting the number of posts to return
Default is to return 5 posts
Filtering posts by category
You will need to pass in the category_slug
Multiple blog roots
If your template has multiple blog root pages (Example a Blog and a Press Releases section), you will need to pass in the Page path to the blog root so that it knows what type of posts to return.
Blog posts from a different Site
By default, get_posts
will grab posts from the current Site. You and optionally provide a different Site ID to pull posts from.
Common use case for this is to pull Corporate blog posts into a Local site
Filtering recent posts by location ID
You can pass in location_id
, include_locationless
as filters
{% set posts = get_posts(filters={'location_id': 12345 'include_locationless': True}) %}
Setting location_id
will limit posts returned to those associated with a location. include_locationless
will include posts that are associated with the set location_id AND posts that have no location association. include_locationless
is only applied if a location_id
is also provided.
now
now
Python datetime object with properties of the current day and time.
Example of outputting the year (i.e. 2024
)
Available properties
now.year
now.month
now.day
now.hour
now.minute
strftime
can be used to format the date. Format variables available here
Example of outputting YYYY-MM-DD
pages
pages
This utility allows you to access and filter the current Pages within a Site.
Output all pages
Filtering pages
Example of filtering pages by template page type
Ordering pages
Accessing custom fields
Get a single page
Available page fields
Standard page fields used in templates
Property | Example | |
---|---|---|
name | Name of the current page | Home |
full_path | Full page path which should be used for HTML links. If under a sub-directory, this path will contain the base_directory of the Local site/page | /local-page/about-us/ |
path | Page path set within the Site Builder. Good for looking up a particular page using | /about-us/ |
custom_page_type | Template page type | page_type_example |
is_published | Boolean value if the page is currently published | True |
is_indexed | Boolean value if the page is indexable. False would be returned if the Page is set to | True |
custom_fields | Array of custom field values. Access via custom_fields.value_name |
pages.as_navigation
pages.as_navigation
Utility for easily creating multi-level navigations for headers, footers and sidebars. Its setup to do recursive looping of items to support any depth
of page navigations
Simple example - Full sitemap
Gets all the pages within the Site, then recursively outputs nested <ul>
and <li>
elements
Sidemenu example
Example of grabbing all pages based on a starting path, then outputting them with a headline. The item.depth == 0
is used to determine it is the first parent page (/services/
) and then the subpages (/services/some-service/)
are output in <ul>
You can also add additional differences in the output based on the depth by using item.depth
primary_location
primary_location
Refers to the primary (first assigned) Location to a Site
If a Site does not have a Location assigned, this will return None
set_schema_overrides
set_schema_overrides
Override and extend any existing schema blocks generated by DevHub. Note: this method will not validate the schema values you enter, so make sure you are adding valid Schema names and values to ensure Google and other search engines can properly read the schema.
Currently supports:
localbusiness
- Extend or overwrite the existing LocalBusiness schema on the local site/page
Last updated