I am very new to Drupal and Twig.

I've a custom Drupal theme I've built, but my client now wants a "blog" system as well. This includes the following features:

  • Show most recent article in a blurb on the home page
  • List out articles with pagination on an archive page
  • Assign categories and/or tags to articles which when visited list out articles similar to the main archive page
  • Show "posted on" date on article page

I've got the last item working just fine, but I can't find anything useful Googling around for the first three items.

I'm using Drupal 8 and twig templates if that makes a difference.

  • That's a little bit too broad and also a quite opinion-based thing. #2 probably should by a Views page, #3 sounds like a new taxonomy and then on the article form a taxonomy reference field and finally a Views block listing articles in a teaser view mode, and the block to be placed in a region beneath the main content and visibility set to be only displayed on articles, #4 can easily be achieved in the node template (if not even directly in the "Manage Display" settings) of articles.
    – leymannx
    Sep 9 '19 at 15:56
  • I would recommend that you look at the Drupal 8 User Guide, which goes through a lot of these exercises. The key here is not to thinking like a themer or a php developer, but think like a Drupal site builder. Specifically you'll want to read from Chapters 6 to Chapter 9 to get a better idea about how to do things using Drupal rather than in HTML or code.
    – mradcliffe
    Sep 9 '19 at 17:31

Everything you listed is super common, almost basic in Drupal projects. So you can find plenty of tutorials and introductory articles about how to do those features.

  1. You can create the latest article blurb Block using Views module (it's in D8 core), then place the Block in a theme region and adjust its visibility to only show on the front page
  2. You can create "Archive" page using Views (pagination is also a feature in Views)
  3. Tag articles with the Taxonomy module (create a Vocabulary with terms inside, then add a Taxonomy reference field on Article Content type). There is a out-of-box View "Taxonomy term" that automatically creates pages for each term and lists the articles tagged with that term
  4. Submitted by and on can also be controled through the interface by editing the Content type settings (you only need twig if you need to override the HTML output)

So get yourself some Drupal Views and Taxonomy tutorials ;)


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.