accessing blogs variable in product liquid

Hello,

I can´t access blogs information in the product page:

{% for blog in blogs %}

{% endfor %}

is returning no results.

Isn´t “blogs” a global variable?

You’ll need to create a menu where you store your blogs first. Go to your Store Admin → Navigation and add a new menu where you store all your blogs, you can call it blogs. Kinda like this:

Once you have done that, try this loop

{% for blog in linklists.blogs.links %}

{% endfor %}

I already have mysite.com/blogs/news linked in my menu!

How do I access all articles in it?

Ok, you can store the blog data itself as an object inside of a variable and then create a for loop to extract the articles

{% for blog in  linklists.blogs.links %}

  {% assign blog_data = blog.object%}

    {% for article in blogs[blog_data.handle].articles %}
       {{article.title}}
    {% endfor %}

  {% endfor %}

Ok i found that I can access single blogs.

So blogs.news.articles works. I just can´t czcle through all blogs

With that you are just looping through the articles of news. If you want to loop through all the blogs, you need to store the handle of each blog.

If you do this:

{% for link in linklists.blogs.links %}
            {% assign blog = link.object %}  
           	{{ blog.handle }}
{% endfor %}

It should print out the name of all of your blogs. That’s good, that means you already have all the keys to access your blogs. Now if you want to print out all the articles from all the blogs, do this.

{% for link in linklists.blogs.links %}
            {% assign blog = link.object %}
            
            {% for article in blogs[blog.handle].articles %}
            	{{article.title}}
            {% endfor %}
{% endfor %}