Route for author page on /?


#1

Hey ghost devs,

I love your publishing software, great great product! :slight_smile:

So, to my question:
Is it possible to route via the routes.yaml the homepage, the root /, to ones authors page?

Thanks!


#2
routes:
  /:
    data: author.{slug}
collections:
  /blog/:
    ...

This should A) give you access to the author on / and it will redirect the target author page to /.
The collection must then live under a different route.

This should work in theory, but I have not tested it. Let me know if it works.


#3

Hi @Kate,

thanks for your fast reply!

Sadly it isn’t working, I’m getting a 422 RC when I visit the page on https://example.com/

Validation (isSlug) failed for slug

But, shouldn’t I tell ghost which author it should route?


#4

Have you replaced “slug” with your author slug?

e.g.

routes:
  /:
    data: author.katharina

#5

Yes I tried it, but I got a other RC 500:

Cannot read property ‘match’ of undefined


#6

That is a template error because you mis-use something in your theme or it’s no longer compatible now that you are using it differently. If you do not specify a template it falls back to index.hbs.

If you set a new template e.g. “template: root” it will load “root.hbs”. It should not error. You can then figure out why your fallback template throwed an error…


#7

Thanks @Kate,

with the template it’s kind of working but data is still missing:

routes:
/:
data: author.ghost
template: author

And I’m using the original casper theme, nothing modified.
So, is it a issue with casper itself, or because I miss-use the routing and it’s not intending to work? :wink:


#8

The static route renders author data as you asked for :slight_smile:

If you want to list posts of the author too, you:

  • might want to use a channel, which allows you to filter by author and gives you e.g. pagination
  • you might want to pull e.g. latest X posts via the get helper for the target author

#9

Hey @Kate,
yeah, that’s what I wanted, thanks! :grin:

routes:
/:
data: author.ghost
template: author
controller: channel
filter: primary_author:ghost


#10

Oh, I just recognized, the menu header is missing, can I also get this to be displayed?


#11

Hi @Kate, hi ghost-team,
any news on the issue, that the ghost header is not displayed?
Looks like the same problems exists here too: Page route for homepage, and blog issue

Update:
Looks like I’ve found two bugs when using this sort of route, the <nav class="site-nav"> is rendering in the source code, but the screen.css has a wrong sizing. If you modify the top to 0, the navigation is back again:

.home-template .site-nav {
position: relative;
top: -70px; --> top: 0

But what’s missing from ghost itself is to render the <a class="site-nav-logo"...> in the `

.

Update 2:
This problem gets triggered by the css min-width: 900px in screen.css, chapter 3. Special Template Styles.

Can anyone reproduce this in Casper 2.9.1+? :slight_smile:


closed #12

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