Get URL with page ID

SOLVE
Regular Contributor

I'm using HTML Modules in a Flexible Column on my page template.

I'm linking to several other COS pages in this HTML Module.

 

It might happen that I need to change URLs of the COS pages. However, when I do this the links in the HTML Module will be broken. 

 

Is there a way to receive page URL with page ID?

 

Thanks.

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
HubSpot Product Team

Hi Sven,

 

Currently, there is no HubL function to return a URL based on page ID, but I'll pass this idea along to the team in charge.

 

It's worth noting that if you do change a pages URL, we'll automatically create a redirect to the new page for you, so your links should still work. More info on that here.

 

Have a great day,

Anthony

Reply
0 Upvotes
4 Replies 4
HubSpot Product Team

Hi Sven,

 

Currently, there is no HubL function to return a URL based on page ID, but I'll pass this idea along to the team in charge.

 

It's worth noting that if you do change a pages URL, we'll automatically create a redirect to the new page for you, so your links should still work. More info on that here.

 

Have a great day,

Anthony

Reply
0 Upvotes
New Member

Hi Anthony,

 

Any update for HubL 2018 for this feature? It's also useful in linking some page from extern website. Example www.myhubspotsite.com/?id={pageID}

 

Best regards,

Ray

Reply
0 Upvotes
Highlighted
HubSpot Product Team

Recently we did add a function for getting a page by ID: https://designers.hubspot.com/en/docs/hubl/hubl-supported-functions#page-by-id

 

This should solve your original issue. Although, this will not work for external linking.

Reply
0 Upvotes
Regular Contributor

The page_by_id() seems to return nothing if the page is one of a blog (i.e. the blog listing page or a blog post page). I'm using this in a custom module with a field of type Page to convert the selection in the Page dropdown to an URL of the page, but now I can't do that.

 

It'd be logical that the function could work with all the pages that are selectable as pages, which includes the blog listing page and blog post pages.

Reply
0 Upvotes