Ghost: Navigation URL and Current Handlebar helpers inconsistent results

When using @blog.navigation directly (outside of a navigation.hbs partial) the {{url}} and {{current}}} handlebars helpers do not work correctly.

When using the {{navigation}} template driven helper to pull in the navigation.hbs partial the {{url}} and {{current}}} handlebars helpers work as expected.

Both cases iterated over the navigation items using {{#foreach navigation}}. In both cases {{label}} worked as expected.

Tested this on index.hbs, page.hbs, post.hbs.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 21 (10 by maintainers)

Commits related to this issue

Most upvoted comments

2 weeks ago I took another good look at this issue. The refactor needed to make the behaviour between @site.navigation and the {{navigation}} helper the same is fairly complex, which is why this issue is still open almost 4 years later. I still don’t see that there’s a particularly clear path to it right now.

In Ghost 2.17 we added the ability to pass attributes to the {{navigation}} and {{pagination}} so that it’s possible to do {{navigation header=true}}, which will solve the main use case here, allowing for different markup in different locations.

We are also experimenting with adding a link helper to handle the concept of “current”. I think between these features, we’ll have enough to cover most use cases. I’ll close this issue once the link helper goes in.

Hi @kevinansfield thanks for looking at this. I emphasized it’s still an issue because it’s been for 3 years around. I can’t use {{navigation}} because as previous posters and how it’s explained in #8972 I’m trying to list navigation items in other parts of the website in a different form and purpose. Maybe it’s hacking the blog system but I expected the core to have persistent behaviour and I find this as a flaw. Not a priority, I can workaround this by hardcoding few things but wanted to share the use case scenario.

As my issue #8972 was closed as duplicate of this one, are we going to get any kind of resolution in foreseeable future, please? Thanks.

{{> "navigation"}} is incorrect. To use the navigation helper, you need to call {{navigation}}. You do not need to specify a navigation.hbs partial unless you want to change the default output, in which case you should base your partial on the default one in Ghost: https://github.com/TryGhost/Ghost/blob/master/core/server/helpers/tpl/navigation.hbs