2023-05-05 13:50:06 +00:00
|
|
|
---
|
2023-10-18 10:59:43 +00:00
|
|
|
title: 'useSeoMeta'
|
2023-05-05 13:50:06 +00:00
|
|
|
description: The useSeoMeta composable lets you define your site's SEO meta tags as a flat object with full TypeScript support.
|
2023-10-18 10:59:43 +00:00
|
|
|
links:
|
|
|
|
- label: Source
|
|
|
|
icon: i-simple-icons-github
|
|
|
|
to: https://github.com/unjs/unhead/blob/main/packages/unhead/src/composables/useSeoMeta.ts
|
|
|
|
size: xs
|
2023-05-05 13:50:06 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
This helps you avoid common mistakes, such as using `name` instead of `property`, as well as typos - with over 100+ meta tags fully typed.
|
|
|
|
|
2024-02-21 17:09:45 +00:00
|
|
|
::important
|
2023-05-05 13:50:06 +00:00
|
|
|
This is the recommended way to add meta tags to your site as it is XSS safe and has full TypeScript support.
|
2023-10-18 10:59:43 +00:00
|
|
|
::
|
2023-05-05 13:50:06 +00:00
|
|
|
|
2023-10-18 10:59:43 +00:00
|
|
|
:read-more{to="/docs/getting-started/seo-meta"}
|
|
|
|
|
|
|
|
## Usage
|
2023-05-05 13:50:06 +00:00
|
|
|
|
|
|
|
```vue [app.vue]
|
|
|
|
<script setup lang="ts">
|
|
|
|
useSeoMeta({
|
|
|
|
title: 'My Amazing Site',
|
|
|
|
ogTitle: 'My Amazing Site',
|
|
|
|
description: 'This is my amazing site, let me tell you all about it.',
|
|
|
|
ogDescription: 'This is my amazing site, let me tell you all about it.',
|
|
|
|
ogImage: 'https://example.com/image.png',
|
|
|
|
twitterCard: 'summary_large_image',
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
|
|
|
|
When inserting tags that are reactive, you should use the computed getter syntax (`() => value`):
|
|
|
|
|
|
|
|
```vue [app.vue]
|
|
|
|
<script setup lang="ts">
|
|
|
|
const title = ref('My title')
|
|
|
|
|
|
|
|
useSeoMeta({
|
|
|
|
title,
|
|
|
|
description: () => `description: ${title.value}`
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2023-08-07 22:10:53 +00:00
|
|
|
There are over 100 parameters. See the [full list of parameters in the source code](https://github.com/harlan-zw/zhead/blob/main/src/metaFlat.ts).
|
2023-10-18 10:59:43 +00:00
|
|
|
|
|
|
|
:read-more{to="/docs/getting-started/seo-meta"}
|