Help? Trying to create a raw.hbs

I am attempting to use the Ghost editor to write a few very specifically formatted pages. I have set up my routes.yaml to pick up a raw.hbs file that I’m working on, and I get that template coming through, but for some reason none of the actual content will show up. I’ve tried a dozen iterations of what looks like the right way to do things, even merging existing .hbs files together, but I’m getting nowhere. Any idea why this shouldn’t just work?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>{{meta_title}}</title>
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div>
<main>
<div>
{{#post}} {{published_at}}  {{/post}}
</div>
</main>
</div>
</body>
</html>

The {{content}} helper is missing:

Nope, tried that. Nothing whatsoever shows up inside the {{#post} {{/post}} block. I assume that somehow it has decided that I don’t have a post to present, but I have created it with some content in it. Here’s how I have my routes.yaml setup.

routes:
/my-page-name/:
template:
- raw

ah ok - so it’s a page you’re pulling in, not a post?

Use {{#page}}{{/page}} - you’ll also need the content helper.

I actually thought that would work, but again, it does not. It does not appear that I am getting any error messages, and although I tried both {{#post}}{{content}}{{/post}} and the same page variant, neither produce anything whatsoever. So, I’m to assume that Ghost doesn’t think I have a page with that path. But I do, and it’s published. I’m very frustrated and very stuck.

I guess I would find a lot of value in more examples of how to build a complete theme, and how to connect something with routes. I see lots of folks building partial content themes, and I’ve studied the error.hbs among others, but actually getting content to flow into a page doesn’t have any verification or error handling that I can find to make the process easier. Maybe some basic analysis of pages and their templates INSIDE the admin tool would be helpful, so I could tell what it WILL use, not just try to look at it from the end user perspective and guess what I’ve done wrong?

routes:
  /my-page-name/:
    template: raw
    data: page.raw

So, apparently you need to have a declaration to specify what data to make available to the template when it’s a custom route. Ok, I guess. Seems like it should NOT interpret those tags, or if it does, throw an error if it does and there is nothing bound to the tag. This is ridiculously difficult to know if there is no error message.

For what it’s worth, this STILL does not seem to get me exactly what I want, because what I’m trying to do is simply inject the {{content}} of the page into a raw.hbs, and it is still forcing a load of style sheets into my section. How can I just get the edited content into my template without the head junk? Any ideas?

For those following along at home… the CORRECT way to do this is as follows:

routes:
   /my-page-name/:
     template: raw
     data: page.my-page-name

This actually injects only the content from the edited page “my-page-name” into the raw.hbs template, exactly where {{#page}{{content}}{{/page}} is in the template, and the file shows up at https://mydomain.com/my-page-name/

The documentation does exist, but you have to read it carefully and guess a bit at the intention, for lack of examples. Thanks for trying to help, Hannah. I appreciate the quick response.

2 Likes