Static home page - routes.yaml formatting error

I’m trying to configure a static home page for -

I want to use a specific page (chainflow.io/home) as the page that is displayed as the static home page.

I’ve researched previous posts on the topic. Here’s my routes.yaml -

routes:
/:
data: page.home
template: page

collections:
/:
permalink: /{slug}/
template:
- index

taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/

When uploading, I get this error -

“The following definition “/” is invalid: Please define a template”

Can someone please help me fix the format?

I’ve tried, this format too, same error -

routes:
/: home
data: page.home
template:
- page

collections:
/:
permalink: /{slug}/
template:
- index

taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/

Discourse stripped your spacing, so it’s hard to tell what your file originally looked like! If you use three “grave accents” (```) to surround your routes file, you can preserve spacing!

I think this should work:

routes:
  /:
    data: page.home
    template: page

collections:
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

Thanks, the format you suggested uploaded successfully!

Now, I’m not seeing the page, only a blank page.

Here’s chainflow.io -

chainflow.io/home looks like same.

Here’s the post in the editor -

Why isn’t the page displaying correctly?

It’s because in the route’s file, you’re saying I want the template to get data from the page named home, and in the template file it’s saying using the *post* you gave me, do this work. I’m not entirely sure what the optimal way to handle an issue like this is, but one method is to create a copy of the page.hbs file in your them and duplicate it to something like homepage.hbs and change {{#post}} to {{#page}} and {{/post}} to {{/page}}

ok, routes.yaml -

  /:
   data: page.home
   template: homepage

collections:
  /:
    permalink: /{slug}/
    template:
      - index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

Now I see this -

I added homepage.hbs, making the edits you suggested, to my theme directory. And restarted the ghost service.

What’s next :thinking: :slightly_smiling_face:

2 things -

  1. Does your routes.yaml file start with routes: or {space}{space}/:? It should start with routes:
  2. Could you share your homepage.hbs file?

I just tried following my instructions and I got it to work :grimacing:

1 Like

OK, it seems to be working at the moment. I’m trying to tweak a few things now. Thanks for your help getting me this far!

If you have any info on why the cannot read "match" of undefined error, that would be super useful so the messaging can be improved! I’m glad you got it working :blush:

So I just switched themes from casper to vapor and copied the homepage.hbs file to the vapor theme directory. Now the page doesn’t show again.

Is it possible the vaport theme doesn’t support whatever we did?

I’d change that message to something specific to the routes.yaml file, e.g. “You’re routes.yaml file is looking for something it can’t find. Please check its configuration.”

We’re pretty sure the error came from handlebars render :grimacing: If you’re willing, please run ghost log --error in your installation so we can see what exactly happened

Every theme has a different underlying structure. Your best bet is to copy vapor’s page.hbs and make the necessary changes to it.

Side note: it will probably be a lot easier to use a local installation of Ghost to set up your site, since you can make changes faster and get more verbose error information

Did I miss any necessary changes here? This is my modified version of Vapor’s page.hbs -

{{!< default}}

<article class="{{post_class}}">

    {{#page}}

    <header>
    {{#if tags}}<div class="post-meta tags">Posted in {{tags}}</div>{{/if}}
    <h1 class="post-title">{{{title}}}</h1>
    <div class="post-meta"><time class="post-date" datetime="{{date format="YYYY-MM-DDTHH:mm:ss.SS\Z"}}">...</time></div>
    </header>

    <section class="post-content">
        {{content}}
    </section>

    <section class="share">
        <p class="info prompt">Share this post</p>
        <a href="http://twitter.com/share?text={{title}}&url={{url absolute="true"}}"
            onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
            <i class="fa fa-2x fa-fw fa-twitter"></i> <span class="hidden">Twitter</span>
        </a>
        <a href="https://www.facebook.com/sharer/sharer.php?u={{url absolute="true"}}"
            onclick="window.open(this.href, 'facebook-share','width=580,height=296');return false;">
            <i class="fa fa-2x fa-fw fa-facebook-square"></i> <span class="hidden">Facebook</span>
        </a>
        <a href="https://plus.google.com/share?url={{url absolute="true"}}"
           onclick="window.open(this.href, 'google-plus-share', 'width=490,height=530');return false;">
            <i class="fa fa-2x fa-fw fa-google-plus-square"></i> <span class="hidden">Google+</span>
        </a>
    </section>

    <footer class="post-footer">

        {{#if primary_author}}
        <section class="author">
            <div class="authorimage" style="background: url({{primary_author.profile_image}})"></div>
            <p class="attr">Author</p>
            <h4><a href="{{primary_author.website}}">{{primary_author.name}}</a></h4>
            <p class="bio">{{primary_author.bio}}</p>
        </section>
        {{/if}}

    </footer>

    {{/page}}

    {{!> comments-disqus}}
    {{!> comments-facebook}}
    {{!> comments-google-plus}}

</article>

Looks like it should work, but only the default part of the template is being sent

It’s not displaying the page content…

With vapor -

With casper -

Any thoughts as to why? And thank you for your continued help and responsiveness!

Ok, I figured out what’s goiong on here!

I have two ghost blogs running on the same server. I think they’re partially sharing the same ./content folders. So, I think I was making the change in the wrong (at least as things are currently configured!) content folder. That’s why I wasn’t seeing the changes.

We’re looking good now, thanks for the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.