Skip to content

Commit 7c6270c

Browse files
authored
docs: add scully-plugin-canonical (#1167)
Added the scully-plugin-canonical information to the community plugin list
1 parent a448bd6 commit 7c6270c

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Canonical Plugin
3+
published: true
4+
lang: en
5+
position: 100
6+
---
7+
8+
# `rss` Plugin
9+
10+
<div class="docs-link_table">
11+
<a class="homepage" href="https://github.com/pjlamb12/scully-plugin-canonical"></a>
12+
<a class="repository" href="https://github.com/pjlamb12/scully-plugin-canonical"></a>
13+
</div>
14+
15+
## Overview
16+
17+
The purpose of the Scully canonical plugin is to take a canonical link attribute from a route and replace the value of the canonical link in the head of a page, or add the link tag if it doesn't exist. This is needed for SEO purposes, if a given article was first published on another site, for example.
18+
19+
## Features
20+
21+
- ✅ Replaces the canonical link with the provided URL for the link tag
22+
- ✅ Adds a canonical link tag if one doesn't exist for a page
23+
24+
## Table of Contents
25+
26+
- [Installation](#installation)
27+
- [Usage](#usage)
28+
- [FAQ](#faq)
29+
30+
## Installation
31+
32+
### NPM
33+
34+
`npm install scully-plugin-canonical --save-dev`
35+
36+
### Yarn
37+
38+
`yarn add scully-plugin-canonical --dev`
39+
40+
## Usage
41+
42+
Render plugins get access to information about the route, and the plugin looks for the title in the following locations in order:
43+
44+
- `route.canonical`
45+
- `route.data.canonical`
46+
- `route.canonicalUrl`
47+
- `route.data.canonicalUrl`
48+
- `route.canonical_url`
49+
- `route.data.canonical_url`
50+
51+
> If the canonical url is set in the frontmatter of a markdown file, the attribute shows up on `route.data`.
52+
53+
To use this plugin, you need to just require the package inside the Scully `config.ts` for your project, i.e. `scully.your-project-name.config.ts`. After requiring the plugin, add it to the `defaultPostRenderers` array for the site:
54+
55+
```ts
56+
// scully.your-project-name.config.ts
57+
require('scully-plugin-canonical');
58+
59+
export const config: ScullyConfig = {
60+
projectRoot: './src',
61+
projectName: 'your-project-name',
62+
outDir: './dist/static',
63+
routes: {},
64+
defaultPostRenderers: ['setCanonicalLinkPlugin'],
65+
};
66+
```
67+
68+
If you only want it to be added to some routes, add it like this:
69+
70+
```ts
71+
// scully.your-project-name.config.ts
72+
require('scully-plugin-canonical');
73+
74+
export const config: ScullyConfig = {
75+
...
76+
routes: {
77+
'/blog/:slug': {
78+
type: 'contentFolder',
79+
slug: {
80+
folder: './blog'
81+
},
82+
postRenderers: ['setCanonicalLinkPlugin']
83+
}
84+
}
85+
...
86+
};
87+
```
88+
89+
That's all it takes for the plugin to be included and run on the pages in your app.

0 commit comments

Comments
 (0)