Course contentsShow
← Web Development
Lesson 1787 of 2,98233. Static Site Generation and JamstackFree lesson

Related Content and Computed Fields

Calculating relationships between content items and generating links during build time for better UX.

Related Content and Computed Fields

You'll learn how to calculate relationships between content items at build time and generate helpful links automatically for a richer user experience.

What Are Computed Fields?

When building static sites, you don't want to manually track which blog posts relate to each other or which products are similar. Computed fields are values calculated during the build process by analyzing your content data—they're not stored in your CMS, but generated on the fly from existing information.

Think of it like a librarian organizing books: instead of manually writing "related books" on each cover, they use a system to identify connections based on genre, author, or topic, then generate those recommendations automatically when printing catalog cards.

Calculating Relationships at Build Time

During your build process (when getStaticProps or getStaticPaths runs), you can:

  • Match tags or categories: Find posts sharing the same taxonomy terms
  • Analyze content similarity: Compare keywords, titles, or descriptions
  • Track author connections: Link all posts by the same author
  • Generate bidirectional links: If Post A references Post B, ensure Post B links back to Post A

For example, when building a blog post page, you might loop through all other posts, compare their tags with the current post's tags, score the matches, and select the top 3 most related posts to display as "You might also like..." links.

The UX Benefit

Pre-computing these relationships means every generated HTML page already contains complete, working links to related content—no client-side JavaScript needed. Users get instant recommendations, and search engines can crawl these connections, improving discoverability.

Key Takeaway: Computed fields and related content are calculated during the build process by analyzing relationships between content items, generating ready-to-use links that enhance navigation and SEO without runtime overhead.