Deep Linking
Browsers allow you to deep link to any element via the ID. This is accomplished with an anchor tag and hashed (#
) href value. When interacting with these anchors, the viewport will automatically attempt to scroll the <body>
element and bring the element into view.
TIP: If you abstract scrolling away from the
<body>
element, this will not work.
Scroll Behavior
You may optionally choose to implement a smooth scroll behavior using CSS.
Generate a Slug
The following provides a barebones implementation for generating a slug based on a heading text value.
Guides
Specific instructions for generating headings will differ based on your meta-framework and your application architecture. Below are a few suggestions, but this is neither a definitive or exhaustive list of all available options.
- Astro - enables you to automatically generate headings using built-in MDX features.
- Svelte - Melt UI provides a headless component solution for Svelte.
- Next.js - Nextra provides a headless component solution for Next.js + MDX.
- Rehype Plugin - a general purpose Rehype plugin for generating a table of contents.