Posts ID

Occasional Contributor

Hi, i'm brand new in hubl, and i'm having trouble understanding how does ID in posts works. I'm working over a web page that was alredy done and I can't find the posts they did, they are using the post id to iterate on it and get some information from it. How do i get the post ID? And most important, if I have a post ID can I find that post and modify it?


This is an example of what they are doing:


{% set blog = html_lang == 'es' ? '5882279228':'5892336346' %}
{% set contents = blog_recent_posts(blog, 22) %}
{% for content in contents|sort(false, false, 'updated') %}
<a href="{{content.absolute_url}}" class="item_destino_destacado w-inline-block item_destino" data-item="{{content.widgets.inicial.body.value}}" data-attr='{{}}'>
<div class="borde_img">
<div class="imagen_principal_destino img_over" style="background-image: url({{content.featured_image}})" data-src="{{content.featured_image}}"></div>
<div class="nombre_destino-s">
<div class="nombre_destino_ptions">{{}}</div>
<div class="linea_horizontal">
<div class="linea_horizontal_negra"></div>
<div class="descripcion_destino">{{ content.post_list_content|truncatehtml(100, "...", false) }}</div>
<div class="more_details_destino">{{ html_lang == 'es' ? 'Más detalles' : 'More details' }}</div>
{% endfor %}



2 Replies 2
HubSpot Alumni

Hi @Roworo,


Welcome. If you're new to HubL, I'd strongly recommend familiarizing yourself with the Developer Info page, which we have documented here: It will show you everything available on a page through HubL and how to access those values.


As for how to find a content ID, probably the easiest way to find that is in the URL for it in-app. So for example if you click into the details page for a blog post, that URL might look like this: The first number is the account ID. The second number (in this example 6984328219) is the ID for this blog post. You can also see that same ID in the editor URL for that blog post: The same would be true for an email or website/landing page.


But your example code is actually a little different than finding blog post IDs. It looks like it's set up to use the blog_recent_posts() function:, which will create a list of the most recently published posts from a specified blog. The function has 2 parameters: the 1st is the ID for the blog to pull posts from, and the 2nd is the number of posts to pull in. On the first line, there's a variable "blog" being set with the ternary operator:


{% set blog = html_lang == 'es' ? '5882279228':'5892336346' %}

So if html_lang is equal to "es", the blog ID will be set to 5882279228. Otherwise it will be set to 5892336346. And then the posts that are pulled in are iterated on and printed into the HTML.


The blog ID can also be found in the in-app URL for the blog's dashboard. So when you navigate to a blog's dashboard, you'll have a URL like The blog's ID in this example is 6983986317. Or alternatively if you were looking at the Developer Info page for your blog, you could access the blog's ID with {{ }} .


As for modifying a post by its ID, are you trying to update the live content for the post? Or just manipulate some of the post's data on a page? If the former, you could plug the ID into the editor URL and edit it in-app. Or you could use our CMS Blog Post API: If you're trying to manipulate some of the data on a separate page, that's possible also, so let me know what you're trying to do in that case.


Let me know if this helps or if you have any questions about it.


Leland Scanlan

HubSpot Developer Support
Occasional Contributor

Thanks a lot, it worked