---
title: "SEO-Friendly URLs in Nuxt"
description: "Create search-optimized URLs using file-based routing. Learn slug formatting, parameter handling, and route patterns that improve rankings."
canonical_url: "https://nuxtseo.com/learn-seo/nuxt/routes-and-rendering/url-structure"
last_updated: "2026-05-06T18:47:33.979Z"
---

<key-takeaways>

- Use hyphens (not underscores), lowercase, under 60 characters
- Path segments for indexed content, query params for filters/sorting
- Set canonical URLs to consolidate filter variations like `?sort=price`

</key-takeaways>

URLs appear in search results before users click. `/blog/vue-seo-guide` tells users what to expect. `/p?id=847` doesn't. Search engines use URLs to understand page hierarchy and relevance. Well-structured URLs improve click-through rates by up to 15%.

Nuxt's file-based routing generates SEO-friendly URLs automatically from your `pages/` directory structure.

## Quick Setup

File-based routing in `pages/`:

```text
pages/
  blog/
    [slug].vue          → /blog/vue-seo-guide
  products/
    [category]/
      [slug].vue        → /products/phones/iphone-15
```

```vue [pages/blog/[slug].vue]
<script setup lang="ts">
const route = useRoute()
const slug = route.params.slug

// Set canonical URL
useHead({
  link: [{
    rel: 'canonical',
    href: `https://mysite.com/blog/${slug}`
  }]
})
</script>
```

## URL Formatting Rules

### Hyphens Over Underscores

[Google treats hyphens as word separators](https://developers.google.com/search/docs/crawling-indexing/url-structure). Underscores connect words into single terms.

```text
✅ /performance-optimization    → "performance" + "optimization"
❌ /performance_optimization    → "performanceoptimization"
```

**Nuxt file structure:**

```text
pages/
  learn-vue-router.vue     ✅ Good
  learn_vue_router.vue     ❌ Bad
```

### Lowercase Only

URLs are case-sensitive. `/About`, `/about`, and `/ABOUT` are different pages. This creates [duplicate content](/learn-seo/nuxt/controlling-crawlers/duplicate-content) issues.

```text
✅ /about
✅ /products/phones
❌ /About
❌ /products/Phones
```

Use [`kebabCase` from scule](https://github.com/unjs/scule) to generate lowercase slugs automatically.

### Keep URLs Short

URLs under 60 characters perform better in search results. Longer URLs get truncated with ellipsis.

**Length comparison:**

<table>
<thead>
  <tr>
    <th>
      URL
    </th>
    
    <th>
      Length
    </th>
    
    <th>
      Result
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        /blog/vue-seo
      </code>
    </td>
    
    <td>
      14 chars
    </td>
    
    <td>
      ✅ Displays fully
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        /blog/comprehensive-guide-to-vue-seo-optimization
      </code>
    </td>
    
    <td>
      50 chars
    </td>
    
    <td>
      ⚠️ Works but verbose
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        /blog/a-comprehensive-guide-to-vue-server-side-rendering-seo-optimization-best-practices
      </code>
    </td>
    
    <td>
      98 chars
    </td>
    
    <td>
      ❌ Truncated in results
    </td>
  </tr>
</tbody>
</table>

**When longer URLs make sense:**

```text
✅ /docs/getting-started/installation-guide    (clear hierarchy)
✅ /blog/2025/fixing-vue-hydration-mismatch   (date + topic)
❌ /the-ultimate-comprehensive-complete-guide  (keyword stuffing)
```

### Keywords Near the Start

[Including keywords in URLs provides a lightweight ranking boost](https://developers.google.com/search/docs/crawling-indexing/url-structure). Front-load important terms.

```text
✅ /vue-router-seo-guide
✅ /seo/vue-best-practices
❌ /guides-and-tutorials-for-seo-in-vue-router
```

But don't sacrifice readability:

```text
pages/
  vue-seo/
    [topic].vue          ✅ Natural keyword placement
  vue-seo-guide-vue-router-seo-tutorial.vue  ❌ Keyword stuffing
```

### Avoid Dates (Usually)

Dates in URLs prevent content updates. `/blog/2024/vue-guide` becomes outdated when you refresh it in 2025.

```text
❌ /blog/2024/vue-router-guide      (looks stale)
❌ /blog/2024/12/17/post-title      (prevents evergreen updates)
✅ /blog/vue-router-guide           (can be updated anytime)
```

**Exception:** Time-sensitive content like news, events, changelogs:

```text
pages/
  changelog/
    [year]/
      [month]/
        [slug].vue       → /changelog/2025/12/new-feature
  events/
    2025/
      [slug].vue         → /events/2025/nuxt-conf
  blog/
    [slug].vue           → /blog/vue-router-guide (evergreen)
```

[Removing dates allows republishing old posts](https://developers.google.com/search/blog/2019/03/help-google-search-know-best-date-for) with new content without changing URLs, which is a strong SEO strategy.

## Path Segments vs Query Parameters

![Path vs Query Parameter Decision](/images/learn-seo/vue/path-vs-query-decision.svg)

Search engines prefer path segments over query parameters. [Path segments are indexed and ranked](https://www.searchenginejournal.com/technical-seo/url-parameter-handling/). Query parameters often cause duplicate content.

**Comparison:**

<table>
<thead>
  <tr>
    <th>
      Type
    </th>
    
    <th>
      Example
    </th>
    
    <th>
      SEO Impact
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Path segments
    </td>
    
    <td>
      <code>
        /products/phones/iphone-15
      </code>
    </td>
    
    <td>
      ✅ Clean, indexed, ranks well
    </td>
  </tr>
  
  <tr>
    <td>
      Query parameters
    </td>
    
    <td>
      <code>
        /products?category=phones&id=15
      </code>
    </td>
    
    <td>
      ⚠️ Duplicate content risk
    </td>
  </tr>
  
  <tr>
    <td>
      Mixed
    </td>
    
    <td>
      <code>
        /products/phones?sort=price
      </code>
    </td>
    
    <td>
      ✅ Path for content, query for filters
    </td>
  </tr>
</tbody>
</table>

**Problems with query parameters:**

```text
/products
/products?sort=price
/products?sort=date
/products?page=2
/products?sort=price&page=2
```

Five URLs, same content. Google sees [duplicate content and wastes crawl budget](https://www.seozoom.com/a-guide-to-query-strings-url-parameters-for-the-seo/). See [Query Parameters](/learn-seo/nuxt/routes-and-rendering/query-parameters) for handling strategies.

### Nuxt Dynamic Routes

Use dynamic segments for content that should be indexed:

```text
pages/
  products/
    [category]/
      [slug].vue        → /products/phones/iphone-15
  blog/
    [year]/
      [month]/
        [slug].vue      → /blog/2025/12/nuxt-seo-guide
  docs/
    [section]/
      [page].vue        → /docs/getting-started/installation
```

### Query Parameters for Filters

Use query parameters for sorting, filtering, and pagination. Set canonical URLs to consolidate these variations. See the [Query Parameters guide](/learn-seo/nuxt/routes-and-rendering/query-parameters) for implementation details including canonical composables and parameter ordering.

## Dynamic Routes

Nuxt's file-based routing creates SEO-friendly URLs automatically. Use descriptive slugs rather than database IDs - `/products/laptop-pro-15` ranks better than `/products/84792`.

### Basic Dynamic Segments

```text
pages/
  blog/
    [slug].vue          → /blog/:slug
```

```vue [pages/blog/[slug].vue]
<script setup lang="ts">
const route = useRoute()
const slug = route.params.slug

// Fetch content based on slug
const { data: post } = await useFetch(`/api/posts/${slug}`)

// Set meta tags
useSeoMeta({
  title: post.value.title,
  description: post.value.excerpt,
  ogUrl: `https://mysite.com/blog/${slug}`
})

useHead({
  link: [{
    rel: 'canonical',
    href: `https://mysite.com/blog/${slug}`
  }]
})
</script>
```

### Nested Dynamic Routes

```text
pages/
  products/
    [category]/
      [slug].vue        → /products/:category/:slug
```

Generates hierarchical URLs:

- `/products/electronics/laptop`
- `/products/clothing/jacket`

```vue [pages/products/[category]/[slug].vue]
<script setup lang="ts">
const route = useRoute()
const category = route.params.category
const slug = route.params.slug

const { data: product } = await useFetch(
  `/api/products/${category}/${slug}`
)

useSeoMeta({
  title: `${product.value.name} - ${category}`,
  description: product.value.description
})
</script>
```

### Catch-All Routes

```text
pages/
  search/
    [...params].vue     → /search/:params*
```

Matches:

- `/search/vue-router`
- `/search/vue-router/recent`
- `/search/vue-router/recent/2025`

**Important:** Catch-all routes create multiple URLs for similar content. Use canonical tags:

```vue [pages/search/[...params].vue]
<script setup lang="ts">
const route = useRoute()
const query = Array.isArray(route.params.params)
  ? route.params.params[0]
  : route.params.params

useHead({
  link: [{
    rel: 'canonical',
    href: `https://mysite.com/search/${query}`
  }]
})
</script>
```

## Slug Generation

Use [`kebabCase` from scule](https://github.com/unjs/scule) (already a Nuxt dependency):

```ts
import { kebabCase } from 'scule'

kebabCase('Vue Router Guide') // "vue-router-guide"
kebabCase('50% Off Sale!') // "50-off-sale"
```

For international content, [Google supports UTF-8 URLs](https://developers.google.com/search/docs/crawling-indexing/url-structure) but they must be percent-encoded when sent over HTTP. Consider whether your audience expects localized slugs or ASCII-only.

## URL Hierarchy and Internal Linking

URL structure defines your site's hierarchy, and that hierarchy directly affects how [internal links](/learn-seo/nuxt/routes-and-rendering/internal-linking) distribute authority. Flat structures (fewer path segments) make pages easier to crawl and link to. Deep nesting (4+ levels) signals low importance to Google.

<table>
<thead>
  <tr>
    <th>
      Structure
    </th>
    
    <th>
      Crawl Depth
    </th>
    
    <th>
      SEO Impact
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        /features/color-extraction
      </code>
    </td>
    
    <td>
      2 levels
    </td>
    
    <td>
      Good, easy to reach
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        /docs/v2/api/reference/methods/extract
      </code>
    </td>
    
    <td>
      6 levels
    </td>
    
    <td>
      Poor, buried content
    </td>
  </tr>
</tbody>
</table>

Keep important pages within 3 clicks of the homepage. Use hub pages (like `/features`) that link to all child pages, creating a clear topic cluster.

### Programmatic SEO URLs

When generating pages at scale ([programmatic SEO](/learn-seo/nuxt/routes-and-rendering/programmatic-seo)), use URL patterns that include target keywords:

```text
pages/
  compare/
    [slug].vue            → /compare/pocketui-vs-css-peeper
  alternatives/
    [slug].vue            → /alternatives/colorzilla
  features/
    [slug].vue            → /features/color-extraction
```

Each pattern targets a different keyword cluster. The keyword in the URL itself is a [lightweight ranking signal](https://developers.google.com/search/docs/crawling-indexing/url-structure). Keep slugs descriptive: `/compare/pocketui-vs-css-peeper` rather than `/compare/1`.

## Testing URL Structure

**View in search results:**

```bash
# Test how Google displays your URLs
site:yoursite.com "vue router"
```

**Check canonicalization:**

Use [Google Search Console URL Inspection](https://search.google.com/search-console) to verify:

- User-declared canonical matches your intent
- Google-selected canonical agrees with your preference
- No conflicting signals from redirects or alternates
