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. craftcms/anchors

ActiveCraft-plugin

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

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

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

Since May 17Pushed 2y ago5 watchersCompare

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

READMEChangelog (3)Dependencies (4)Versions (20)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

43

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

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

794d 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

[craftcms/ckeditor

Edit rich text content in Craft CMS using CKEditor.

48359.1k52](/packages/craftcms-ckeditor)[craftcms/commerce

Craft Commerce

243416.9k153](/packages/craftcms-commerce)[craftcms/webhooks

Post webhooks when events are triggered in Craft CMS.

84135.5k1](/packages/craftcms-webhooks)[craftcms/store-hours

This plugin adds a new “Store Hours” field type to Craft, for collecting the opening and closing hours of a business for each day of the week.

61102.9k1](/packages/craftcms-store-hours)[craftcms/generator

Craft CMS component generator

88377.0k38](/packages/craftcms-generator)[craftcms/simple-text

This plugin adds a new “Simple Text” field type to Craft, which provides a textarea that’s optimized for entering documentation.

2624.1k](/packages/craftcms-simple-text)

PHPackages © 2026

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