{{post.content}} empty inside script tag

Hey everyone, I’m trying to get the content of a post using the post helper inside a script tag in my footer file.

However I’m getting an empty string for the content property. I need this to change my Structure Data, since there seems no easy way to customize the Structure Data, that’s why I’m doing it this way.

My code just to check if I get the properties:

 window.post = {
          id: "{{post.id}}", 
          comment_id: "{{post.comment_id}}" ,
          title : "{{post.title }}",
          slug : "{{post.slug }}",
          excerpt : "{{post.excerpt }}",
          content : "{{post.content }}",
          url : "{{post.url }}",
          feature_image : "{{post.feature_image }}",
          feature_image_alt : "{{post.feature_image_alt}}",
          feature_image_caption: "{{post.feature_image_caption}}",
          featured : "{{post.featured }}",
          page : "{{post.page }}",
          meta_title : "{{post.meta_title }}",
          meta_description : "{{post.meta_description }}",
          published_at : "{{post.published_at }}",
          updated_at : "{{post.updated_at }}",
          created_at : "{{post.created_at }}",
          primary_author : "{{post.primary_author }}",
          tags : "{{post.tags }}",
          primary_tag : "{{post.primary_tag }}",
        };

The output of the console, when I check the post variable

comment_id: "61f8490d89c09a470c89e9d5"
content: ""
created_at: "2022-01-31T20:39:41.000+00:00"
excerpt: "Lorem ipsum dolor sit amet"
feature_image: ""
feature_image_alt: ""
feature_image_caption: ""
featured: "false"
id: "61f8490d89c09a470c89e9d5"
meta_description: ""
meta_title: ""
page: ""
primary_author: "[object Object]"
primary_tag: ""
published_at: "2022-01-31T20:40:03.000+00:00"
slug: "test"
tags: ""
title: "Test"
updated_at: "2022-01-31T20:51:41.000+00:00"
url: "http://localhost:2368/test/"

As you can see, content is empty, I don’t know If I’m doing something wrong. I’d really appreciate some help.

Thanks!

Is it a members-only post? If you’re logged out and requesting a members-only post, then post.content will return null

Hey John, no. I set the the post to be public

I’m using a local install as I’m testing locally first. I don’t if that affects somehow.

Hey @danielcruz,

It should be {{post.html}}. You can also see all available data here. Ghost Content API Documentation