Zum Inhalt springen

PageWithTags

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

The PageWithTags component wraps your content and displays tags at configurable positions (top, bottom, or both).

See live demo →

import { PageWithTags } from 'starlight-tags/components';
PropTypeDefaultDescription
tagIdsstring[]-Specific tag IDs to display
tagsProcessedTag[]-Pre-fetched tag objects (for advanced use)
position'top' | 'bottom' | 'both''bottom'Where to display tags
showTitlebooleantrueShow “Tags” heading (bottom only)

Display tags from the current page’s frontmatter:

import { PageWithTags } from 'starlight-tags/components';
<PageWithTags>
<h1>My Page Title</h1>
<p>Page content goes here...</p>
</PageWithTags>

Display specific tags by ID:

<PageWithTags tagIds={['configuration', 'guide']}>
<p>Content with specific tags...</p>
</PageWithTags>

Tags appear after the content with a separator:

<PageWithTags position="bottom">
<slot />
</PageWithTags>

Tags appear before the content:

<PageWithTags position="top">
<slot />
</PageWithTags>

Tags appear at both top and bottom:

<PageWithTags position="both">
<slot />
</PageWithTags>

Hide the “Tags” heading at the bottom:

<PageWithTags showTitle={false}>
<slot />
</PageWithTags>
<PageWithTags
tagIds={['components', 'reference', 'advanced']}
position="both"
showTitle={false}
>
<article>
<h1>Component Guide</h1>
<p>Content here...</p>
</article>
</PageWithTags>

The component adds margin and border styling:

  • Top position: Margin below tags
  • Bottom position: Margin above tags with a top border separator

Override the default styles:

.fb-page-tags {
margin: 1rem 0;
}
.fb-page-tags--top {
margin-bottom: 2rem;
}
.fb-page-tags--bottom {
border-top: 2px solid var(--sl-color-accent);
padding-top: 1rem;
}

The component respects the hideTags frontmatter property. When hideTags: true is set in a page’s frontmatter, the component renders nothing (only the slotted content is displayed):

---
title: Internal Documentation
tags:
- configuration
- troubleshooting
hideTags: true
---
import { PageWithTags } from 'starlight-tags/components';
<PageWithTags position="both">
<!-- Tags won't display at top or bottom because hideTags is true -->
<p>This content will still render, but without tags.</p>
</PageWithTags>

The page will still appear in tag listings (e.g., /tags/configuration), but tags won’t be displayed on the page itself. This is useful for internal documentation or pages where you want tag-based organization without visible tag badges.

Wondering which component to use? Here’s a quick comparison:

FeaturePageWithTagsPageTags
Auto-reads frontmatter✅ Yes✅ Yes
Accepts tagIds✅ Yes❌ No
Wraps content✅ Yes (via slot)❌ No
Position controltop / bottom / both❌ Manual placement
Separator line✅ Yes (bottom position)❌ No
”Tags” title✅ Optional❌ No
Best forLayout templatesDrop-in tag display

Choose PageWithTags when you need:

  • Tags frame your content automatically through content wrapping
  • Enforces consistent positioning across pages (great for layout components)
  • Lets you specify which tags to display via tagIds
  • Provides visual separation with a built-in separator line and optional “Tags” title
<PageWithTags position="both">
<article>
<slot />
</article>
</PageWithTags>

Choose PageTags when you want:

  • Drop <PageTags /> anywhere in your MDX for simplicity
  • Place tags exactly where you want in your content
  • Display tags inline as part of content flow
<PageTags /> <!-- That's it! -->

It’s important to understand the difference between components you use in your content and the pages automatically generated by the plugin:

AspectPageWithTags (Component)/tags Index Page
TypeComponent you importAuto-generated route
PurposeWrap content with tagsList all tags in system
ShowsTags for a single pageAll tags with stats & cloud
DataAuto-fetched or via tagIdsFetches all tags automatically
LocalizationHardcoded title (customizable)Fully localized UI
Usage<PageWithTags>...</PageWithTags>Visit /tags URL

The plugin automatically creates these routes:

  • /tags is the index page listing all tags with stats, tag cloud, and alphabetical navigation
  • /tags/[tag-slug] are individual tag pages showing all pages with that tag

These pages are fully localized and styled - you don’t need to create them yourself.