PageWithTags
The PageWithTags component wraps your content and displays tags at configurable positions (top, bottom, or both).
Import
Section titled “Import”import { PageWithTags } from 'starlight-tags/components';| Prop | Type | Default | Description |
|---|---|---|---|
tagIds | string[] | - | Specific tag IDs to display |
tags | ProcessedTag[] | - | Pre-fetched tag objects (for advanced use) |
position | 'top' | 'bottom' | 'both' | 'bottom' | Where to display tags |
showTitle | boolean | true | Show “Tags” heading (bottom only) |
Basic Usage
Section titled “Basic Usage”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>Specific Tags
Section titled “Specific Tags”Display specific tags by ID:
<PageWithTags tagIds={['configuration', 'guide']}> <p>Content with specific tags...</p></PageWithTags>Positions
Section titled “Positions”Bottom (Default)
Section titled “Bottom (Default)”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>Without Title
Section titled “Without Title”Hide the “Tags” heading at the bottom:
<PageWithTags showTitle={false}> <slot /></PageWithTags>Combined Options
Section titled “Combined Options”<PageWithTags tagIds={['components', 'reference', 'advanced']} position="both" showTitle={false}> <article> <h1>Component Guide</h1> <p>Content here...</p> </article></PageWithTags>Styling
Section titled “Styling”The component adds margin and border styling:
- Top position: Margin below tags
- Bottom position: Margin above tags with a top border separator
Custom Styling
Section titled “Custom Styling”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;}Hiding Tags
Section titled “Hiding Tags”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 Documentationtags: - configuration - troubleshootinghideTags: 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.
PageWithTags vs PageTags
Section titled “PageWithTags vs PageTags”Wondering which component to use? Here’s a quick comparison:
| Feature | PageWithTags | PageTags |
|---|---|---|
| Auto-reads frontmatter | ✅ Yes | ✅ Yes |
| Accepts tagIds | ✅ Yes | ❌ No |
| Wraps content | ✅ Yes (via slot) | ❌ No |
| Position control | ✅ top / bottom / both | ❌ Manual placement |
| Separator line | ✅ Yes (bottom position) | ❌ No |
| ”Tags” title | ✅ Optional | ❌ No |
| Best for | Layout templates | Drop-in tag display |
When to Use PageWithTags
Section titled “When to Use PageWithTags”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>When to Use PageTags
Section titled “When to Use PageTags”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! -->Components vs Auto-Generated Pages
Section titled “Components vs Auto-Generated Pages”It’s important to understand the difference between components you use in your content and the pages automatically generated by the plugin:
| Aspect | PageWithTags (Component) | /tags Index Page |
|---|---|---|
| Type | Component you import | Auto-generated route |
| Purpose | Wrap content with tags | List all tags in system |
| Shows | Tags for a single page | All tags with stats & cloud |
| Data | Auto-fetched or via tagIds | Fetches all tags automatically |
| Localization | Hardcoded title (customizable) | Fully localized UI |
| Usage | <PageWithTags>...</PageWithTags> | Visit /tags URL |
Auto-Generated Pages
Section titled “Auto-Generated Pages”The plugin automatically creates these routes:
/tagsis 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.