1

I'm trying to understand the best or most common approach to creating unique author/user pages that list that user's blog entries.

This question was helpful for how to process the results.

However, I'm stuck in where to define the Template that will handle the user pages. Outside of creating a publicly accessible twig file, is there a better place and process to define a Template within the Admin settings?

With a general twig file, including SEO meta items becomes more challenging.

Thoughts on how to approach?

1 Answer 1

2

The brief answer is that the Settings > Routes feature is perfect for that. You can add tokens as URL segments that are provided to any template you select as variables. The same can be accomplished with the routes.php config file.

For a very small organization that should work well. If not a very small org, here is another option to consider:

Nowadays I create a dedicated Authors channel separate from Craft Users. The Blog channel gets an Author relation field, and the Authors channel might get a User relation field. At the end of the day, an Author is metadata, and making it a system user is potentially a conflation that introduces other issues, e.g. external contributing authors that you don't want to give user accounts to.

Pros (esp for medium-to-large orgs):

  • Author SEO is handled just like any other channel
  • Listing pages are also just like any other channel (problem solved)
  • Can have outside contributor profiles without creating User accounts
  • Author profile fields can be specialized without polluting User fields
  • An editor or content manager can publish articles for any Author
  • etc.

Cons:

  • Some custom module work to sync Author entries with Users if necessary

The only possible magic to implement is assigning a related Author to the to a newly created entry based on the current user if that's the expected behavior. Also, if you want to keep common User fields and Author channel fields in sync, such as email, names, etc. then there's that.

Hope that helps!

3
  • Thank you so much! Your answer is incredibly well thought out and answers all scenarios. Dec 22, 2021 at 14:18
  • One question: how do you tie the query back to the Blog relationship? I have tried variations of craft.entries.section('blog').relatedTo(authors).all() with no luck. Am I missing something? Dec 22, 2021 at 15:01
  • I figured it out! For others that might have trouble, first, you must set a variable, such as set author = entry.id then use that variable in the relatedTo method. Dec 22, 2021 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.