-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,394 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: Mastering Meta in Vue & Nuxt | ||
description: Learn how to effectively manage web crawlers in Vue and Nuxt applications to optimize SEO and protect your content. | ||
navigation: | ||
title: 'Slack' | ||
publishedAt: 2024-11-03 | ||
updatedAt: 2024-11-03 | ||
readTime: 10 mins | ||
keywords: | ||
- vue crawler control | ||
- web crawlers | ||
- robots.txt | ||
- sitemap.xml | ||
--- | ||
|
||
todo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: Mastering Meta in Vue & Nuxt | ||
description: Learn how to effectively manage web crawlers in Vue and Nuxt applications to optimize SEO and protect your content. | ||
navigation: | ||
title: 'Twitter - X Cards' | ||
publishedAt: 2024-11-03 | ||
updatedAt: 2024-11-03 | ||
readTime: 10 mins | ||
keywords: | ||
- vue crawler control | ||
- web crawlers | ||
- robots.txt | ||
- sitemap.xml | ||
--- | ||
|
||
todo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: Trailing Slashes in Vue & Nuxt | ||
description: Learn why we might use a trailing slash, best practices for them and how to handle them in Nuxt. | ||
navigation: | ||
title: 'Routes and rendering' | ||
publishedAt: 2024-10-25 | ||
updatedAt: 2024-10-25 | ||
icon: i-tabler-slashes | ||
--- | ||
|
113 changes: 113 additions & 0 deletions
113
docs/content/learn-todo/3.routes-and-rendering/3.trailing-slashes.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
--- | ||
title: Complete Trailing Slashes Guide for Vue & Nuxt | ||
description: Learn why trailing slashes matter (or don't), how to implement them correctly in Vue & Nuxt, and when you can ignore them entirely. | ||
icon: i-tabler-slashes | ||
navigation: | ||
title: 'Trailing Slashes' | ||
publishedAt: 2024-11-06 | ||
updatedAt: 2024-11-06 | ||
readTime: 8 mins | ||
keywords: | ||
- trailing slashes | ||
- vue routing | ||
- nuxt routes | ||
- technical seo | ||
--- | ||
|
||
## Introduction | ||
|
||
A trailing slash is the "/" at the end of a URL. For example: | ||
- With trailing slash: `/about/` | ||
- Without trailing slash: `/about` | ||
|
||
While trailing slashes don't directly impact SEO rankings, they can create technical challenges: | ||
|
||
1. **Duplicate Content**: When both `/about` and `/about/` serve the same content without proper canonicalization, search engines have to choose which version to index. While Google is generally good at figuring this out, it's better to be explicit. | ||
|
||
2. **Crawl Budget**: On large sites, having multiple URLs for the same content can waste your [crawl budget](/learn/controlling-crawlers#improve-organic-traffic). | ||
|
||
3. **Analytics Accuracy**: Different URL formats can split your analytics data, making it harder to track page performance. | ||
|
||
The solution is simple: pick one format and stick to it by [redirecting](/learn/controlling-crawlers/redirects) the other and set | ||
[canonical URLs](/learn/controlling-crawlers/canonical-urls). | ||
|
||
|
||
## Vue Router | ||
|
||
By default, all routes in Vue Router are case-insensitive and match routes with or without trailing slashes. For example, `/users` will match: | ||
- `/users` | ||
- `/users/` | ||
- `/Users/` | ||
|
||
### Quick Implementation | ||
|
||
Control trailing slash behavior through router configuration: | ||
|
||
```ts | ||
import { createRouter } from 'vue-router' | ||
|
||
const router = createRouter({ | ||
strict: true, | ||
}) | ||
``` | ||
|
||
|
||
## Quick Implementation | ||
|
||
In Vue, you can control trailing slash behavior through router configuration: | ||
|
||
::code-group | ||
|
||
\```ts [Vue Router] | ||
import { createRouter } from 'vue-router' | ||
|
||
const router = createRouter({ | ||
// Make routes case-sensitive and enforce trailing slash rules | ||
strict: true, | ||
sensitive: true, | ||
// your other config | ||
}) | ||
\``` | ||
|
||
\```ts [Nuxt Config] | ||
export default defineNuxtConfig({ | ||
// Remove trailing slashes (default) | ||
router: { | ||
trailingSlash: false | ||
} | ||
}) | ||
\``` | ||
|
||
:: | ||
|
||
### Router Options Explained | ||
|
||
Vue Router provides two key options for URL matching: | ||
|
||
- `strict: true` - Enforce trailing slash rules (e.g., `/users` won't match `/users/`) | ||
- `sensitive: true` - Make routes case-sensitive (e.g., `/users` won't match `/Users`) | ||
|
||
You can set these globally or per-route: | ||
|
||
\```ts | ||
const router = createRouter({ | ||
routes: [ | ||
{ | ||
path: '/users', | ||
// Override global settings per-route | ||
strict: true, | ||
sensitive: true, | ||
component: Users | ||
} | ||
] | ||
}) | ||
\``` | ||
|
||
## Avoiding Duplicate Content | ||
|
||
The main reason to care about trailing slashes is to avoid having the same content accessible at multiple URLs: | ||
|
||
```bash | ||
https://mysite.com/about/ | ||
https://mysite.com/about | ||
https://mysite.com/About # with case-insensitive routing |
Oops, something went wrong.