Drupal content flows through filters and sorting into page, block, and feed displays

Editorial illustration; the query builder and displays are representative of a Drupal Views workflow.

Every Drupal project eventually hits the same turning point. You start with a handful of content types and a main menu, and then the client asks for a list: upcoming training workshops, circulars filtered by year, related case studies on a service page, or an RSS feed for announcements. You could write a custom controller with Drupal::entityQuery('node') for each one, but maintaining separate render arrays and pagers for every minor variation gets tedious fast.

Drupal core’s Views module exists to solve that exact problem. It lets you define a database query once—picking a base table, filters, sorting, and output format—and expose it as a page, a block, a feed, or even a REST/JSON export. The catch is that Views makes it dangerously easy to click together a sprawling query that nobody understands six months later. Treating each View as a focused, well-scoped content product keeps it an asset instead of a performance bottleneck.

How Views separates the query from the display

Under the hood, a View is a configuration entity stored in YAML (for example, views.view.events.yml when exported with drush cex). It splits the work into two parts: the query definition (base table like node_field_data, filter criteria, sort criteria, relationships, and contextual filters) and one or more displays.

That separation is where the real leverage lives. You can build one query for published events sorted by start date, then expose a full /events Page display with a 12-item pager and exposed category filter, alongside a Block display on the homepage showing only the next three items. Both displays share the same editorial rule—what counts as an active event—without duplicating query logic across templates or custom modules.

Still, Views can only work with the structure you give it. If editors type event dates into the node title instead of using a dedicated Date field, or use free-text tags instead of a controlled taxonomy vocabulary, no amount of Views configuration will produce a reliable listing.

Start with one plain-English content question

Before opening /admin/structure/views, write down what the listing actually promises in one sentence:

“Show published Event nodes tagged training, ordered by field_event_date ascending, displaying title, date, venue, and a link, 10 items per page.”

That single sentence locks down the entity type, publication state, taxonomy filter, sort field, displayed fields, and pagination. It also gives you a concrete acceptance test to show the content editor, who does not care whether you used a relationship or an entity reference field to get there.

Starting from “let’s see what Views can do” usually ends in bloated queries with three unnecessary relationships and five exposed filters that nobody asked for.

Building a clean View without over-engineering

Once the question is clear, build the smallest version that answers it:

  1. Verify the content model first. Confirm the fields, taxonomy vocabularies, and permissions exist. A dedicated date or boolean field is always more reliable than string matching on titles.
  2. Create a focused View. Give it a clear machine name (like upcoming_training_events), add only the required filter criteria (Published = Yes, Content type = Event), and start with a Page display so you can inspect the full output, pager, and URL behaviour.
  3. Configure the empty state and formatting. A blank block region looks like a broken layout. Add a simple “No results” text area or a link back to the main archive so visitors are not left staring at empty space.
  4. Inspect the generated SQL. Enable query preview in Views settings (drush config:set views.settings ui.show.sql_query 1) while developing. Seeing the actual SELECT and JOIN statements immediately reveals if a filter or relationship is doing something unexpected.
  5. Test as an anonymous user and an editor. Never trust the admin preview alone. Unpublished drafts, restricted content types, or private files can behave completely differently when viewed by an anonymous visitor.
  6. Prune unused displays. Every display is a maintenance contract. If someone created a test block three sprints ago and never placed it in Block Layout, delete it before it confuses the next developer.

Performance, relationships, and caching trade-offs

Views saves you from writing boilerplate PHP, not from thinking about SQL. Adding a relationship—say, pulling in an author profile or a referenced organisation—creates a JOIN that can easily multiply rows and produce duplicate nodes in your list. Toggling Distinct in the query settings is often used as a quick band-aid, but it adds DISTINCT overhead without fixing why the join multiplied rows in the first place. Sometimes rendering the entity via a compact View Mode (like Teaser or Card) is cleaner and easier to theme than pulling twelve individual fields through joins.

Caching matters just as much. By default, Views uses Tag-based caching, which attaches cache tags like node_list or node_list:event so the cache invalidates automatically when an Event node is saved. That works well for most listings. However, if your View uses a relative date filter (like field_event_date >= now), tag-based caching alone will not expire the list at midnight because no node was edited. In that case, switch to Time-based caching with an appropriate TTL, or document why a short cache lifetime is needed so another developer does not blindly turn it off later.

When you modify a shared View, remember that changes to the “All displays” scope affect every Page, Block, and Feed attached to it. If you only want to change the homepage block, make sure the dropdown at the top of the modal says This block (override) before clicking Apply.

When Views is the wrong tool

Do not reach for Views just because it is installed. A static landing page with four hand-picked links is better served by a Menu or a Layout Builder block than a View with hardcoded node IDs. Similarly, if a feature requires complex conditional logic, external API merging, or custom access calculations that fight the Views UI, a small custom block or controller using Drupal::entityQuery() and a dedicated Twig template is far easier to read, code-review, and unit-test.

Views is also not a fix for messy data. If editors cannot explain why a node appeared or disappeared from a listing, the underlying content model or editorial workflow needs attention—not another exposed filter.

For related Drupal workflows that pair well with structured listings, see:

Keep each View tied to a clear editorial question, check the SQL preview before shipping, test with non-admin roles, and delete displays that no longer earn their keep.

Sources