Get URL with page ID

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.

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

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

Recently we did add a function for getting a page by ID: HubL functions - HubSpot docs

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

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.

Hi Sven,

content_by_id function do the job

Regards

Giorgio

Hi Sven,

currently content_by_id function do the job

Regards

Giorgio