PHPackages                             craftcms/anchors - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. craftcms/anchors

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

craftcms/anchors
================

Add anchor links to headings in your Craft CMS website content.

3.4.0(2y ago)4734.0k↓70.8%7[1 issues](https://github.com/craftcms/anchors/issues)[2 PRs](https://github.com/craftcms/anchors/pulls)MITPHPPHP ^8.0.2CI passing

Since May 17Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/craftcms/anchors)[ Packagist](https://packagist.org/packages/craftcms/anchors)[ RSS](/packages/craftcms-anchors/feed)WikiDiscussions 3.x Synced yesterday

READMEChangelog (3)Dependencies (4)Versions (21)Used By (0)

Anchors for Craft CMS
=====================

[](#anchors-for-craft-cms)

This plugin makes it possible to automatically add linkable anchors to HTML headings in Craft.

The anchors are named based on the heading text. The algorithm Anchors uses to convert the heading text to IDs is similar to Craft’s algorithm for automatically generating entry slugs.

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 4.0.0+ or 5.0.0+.

Installation
------------

[](#installation)

You can install this plugin from the Plugin Store or with Composer.

#### From the Plugin Store

[](#from-the-plugin-store)

Go to the Plugin Store in your project’s Control Panel and search for “Anchors”. Then click on the “Install” button in its modal window.

#### With Composer

[](#with-composer)

Open your terminal and run the following commands:

```
# go to the project directory
cd /path/to/my-project.test

# tell Composer to load the plugin
composer require craftcms/anchors

# tell Craft to install the plugin
./craft install/plugin anchors
```

Templating
----------

[](#templating)

To use Anchors in your templates, just pass some HTML into the `|anchors` filter.

```
{{ entry.body|anchors }}
```

By default, the `anchors` filter will only search for ``, ``, and `` tags. You can customize which tags it searches for by passing in a comma-separated list of tag names.

```
{{ entry.body|anchors('h2,h3') }}
```

The `anchors` filter will convert any non-ASCII characters to ASCII, using the current site’s language’s ASCII character mappings by default.

If you are displaying content in a different language than the current site, use the `language` argument to override which ASCII character mappings should be used:

```
{{ entry.body|anchors(language=entry.site.language) }}
```

By default, `anchors` filter will lowercase words that are all uppercase and lowercase the first letter in any other case.

If you want the anchors to always be lowercase, you can use the `lowercase` argument:

```
{{ entry.body|anchors(lowercase=true) }}
```

Configuration
-------------

[](#configuration)

To configure Anchors, create a new `anchors.php` file within the `config/` folder, which returns an array.

The following config settings are supported:

- `anchorClass` – The class name that should be given to named anchors. (Default is `null`, meaning no class will be given.)
- `anchorLinkPosition` – The position that anchor links should have within headings, relative to the heading text (`'before'` or `'after'`). (Default is `'after'`.)
- `anchorLinkClass` – The class name that should be given to anchor links. (Default is `'anchor'`.)
- `anchorLinkText` – The visible text that anchor links should have. (Default is `'#'`'.)
- `anchorLinkTitleText` – The title/alt text that anchor links should have. If `{heading}` is included, it will be replaced with the heading text the link is associated with. (Default is `'Direct link to {heading}'`.)
- `useAdditionalTagToAnchorTo` – Whether to render an additional tag above the heading and use it to scroll to when the anchor link is clicked. If set to `false`, anchor id is added to the heading. (Default is `true`.)

Plugin API
----------

[](#plugin-api)

Other plugins can take advantage of Anchors using the provided API.

```
$parsedHtml = \craft\anchors\Plugin::getInstance()->parser->parseHtml($html);
```

Like the `|anchors` templating filter, `parseHtml()` also allows you to specify which HTML tags should get anchors.

```
$parsedHtml = \craft\anchors\Plugin::getInstance()->parser->parseHtml($html, 'h2,h3');
```

You can also pass some heading text directly into Anchors to get its generated anchor name:

```
$anchorName = \craft\anchors\Plugin::getInstance()->parser->generateAnchorName($headingText);
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance58

Moderate activity, may be stable

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 72.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~138 days

Recently: every ~64 days

Total

19

Last Release

840d ago

Major Versions

2.3.1 → 3.0.0-beta.12022-03-04

2.4.0 → 3.1.02022-12-16

2.4.1 → 3.3.02023-07-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/3ccdf8b493035de2343c55bd889513e3af5c04d5823482a2b186ad16adb1c3e3?d=identicon)[brandonkelly](/maintainers/brandonkelly)

---

Top Contributors

[![brandonkelly](https://avatars.githubusercontent.com/u/47792?v=4)](https://github.com/brandonkelly "brandonkelly (92 commits)")[![angrybrad](https://avatars.githubusercontent.com/u/61869?v=4)](https://github.com/angrybrad "angrybrad (27 commits)")[![i-just](https://avatars.githubusercontent.com/u/4500340?v=4)](https://github.com/i-just "i-just (6 commits)")[![benjamindavid](https://avatars.githubusercontent.com/u/2911900?v=4)](https://github.com/benjamindavid "benjamindavid (1 commits)")[![MakeilaLundy](https://avatars.githubusercontent.com/u/19892516?v=4)](https://github.com/MakeilaLundy "MakeilaLundy (1 commits)")

---

Tags

anchor-linkscraft-plugincraft2craft3craftcmsyii2htmlcmsyii2craftcmsanchors

### Embed Badge

![Health badge](/badges/craftcms-anchors/health.svg)

```
[![Health](https://phpackages.com/badges/craftcms-anchors/health.svg)](https://phpackages.com/packages/craftcms-anchors)
```

###  Alternatives

[spicyweb/craft-neo

A Matrix-like field type with block hierarchy

393813.5k10](/packages/spicyweb-craft-neo)[craftcms/ckeditor

Edit rich text content in Craft CMS using CKEditor.

47406.3k76](/packages/craftcms-ckeditor)[craftcms/feed-me

Import content from XML, RSS, CSV or JSON feeds into entries, categories, Craft Commerce products, and more.

293952.6k33](/packages/craftcms-feed-me)[verbb/formie

The most user-friendly forms plugin for Craft.

102393.6k69](/packages/verbb-formie)[craftcms/webhooks

Post webhooks when events are triggered in Craft CMS.

84139.0k1](/packages/craftcms-webhooks)[verbb/comments

Add comments to your site.

13753.9k](/packages/verbb-comments)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
