当前位置:网站首页>Nuxt - 每个页面单独设置 SEO 相关标签及网页标题、图标等(页面配置 head)
Nuxt - 每个页面单独设置 SEO 相关标签及网页标题、图标等(页面配置 head)
2022-06-29 03:56:00 【王佳斌】
前言
您一定知道,要想配置一些
SEO相关的标签,就要在项目根目录下nuxt.config.js→head字段进行。
请注意,nuxt.config.js 文件中所配置的是全局的,
并非 “独立” 应用到每个页面,也就是说所有页面都用这个全局配置。
但要是想要更加 “全面 SEO” ,您必须为每个页面 单独设置。
解决方案
Nuxt 提供了便捷的钩子,可以让我们在页面中轻松定义。
例如 index.vue 页面,为其配置的代码如下:
<template>
<div>
...
</div>
</template>
<script> export default {
data() {
return {
} }, // 与 data 钩子函数同级 head() {
// 直接返回所有SEO相关及页面配置 return {
title: "我是标题", meta: [ {
charset: "utf-8" }, {
name: "viewport", content: "width=device-width, initial-scale=1" }, {
hid: "description", name: "description", content: "我是首页内容,这是描述" }, {
name: "renderer", content: "webkit" }, // 更多标签... ], // 该页图标 // link: [{ rel: "icon", type: "image/x-icon", href: "/favicon1.ico" }], } }, } </script>
每个页面都具有 head() 这个钩子函数。
边栏推荐
- How to keep database and cache consistent
- 高性能限流器 Guava RateLimiter
- Do you feel confused when you study at three in the morning?
- The second meeting of the Second Council of Euler open source community was held, and Xinhua III, hyperfusion and Godson Zhongke became members of the Council
- [tcapulusdb knowledge base] Introduction to tcapulusdb tcapsvrmgr tool (III)
- [FPGA mathematical formula] use FPGA to realize common mathematical formulas
- 科班出身,结果外包都不要
- Share 60 divine vs Code plug-ins
- 20款IDEA 神级插件 效率提升 30 倍,写代码必备
- Set hardware breakpoint instruction for ejtag under the PMON of the Godson development board
猜你喜欢

Common methods of JS date and time

sql两列变为多行过滤显示

Implementation of b+ tree index based on xlsx

Share 60 divine vs Code plug-ins

How sqlserver queries and removes results with null fields in the whole column

百度智能云服务网格产品CSM发布 | 火热公测中

Cloud native weekly | grafana 9 was officially released; The Chinese version of cloud native vocabulary is now online

Seura 2 test code summary

Mobileone: the mobile terminal only needs 1ms of high-performance backbone

基于xlsx的B+树索引实现
随机推荐
【C语言】 详解线程退出函数 pthread_exit
2022年 6月27号 《暑假感悟篇一》路程的选择权。
使用roslaunch为Gazebo加载自定义模型时黑屏、报错问题
88. (cesium chapter) cesium aggregation diagram
Data collection and management [8]
Whose encryption key is written in the code? (that's you)
leetcode - 295. 数据流的中位数
Why are you a test / development programmer? Can you recall
Idea of importing point cloud map into gazebo
An annotation elegant implementation of interface data desensitization
mysql动态加表只能加小表,加大表跑着跑着任务就不读数据了,有什么解决办法吗
[Brillouin phenomenon] Study on simultaneous measurement system of Brillouin temperature and strain distribution in optical fiber
科班出身,结果外包都不要
中小型企业网络的组建
[fpga+sin] FPGA implementation of sinusoidal signal generator module based on DDS (direct digital synthesis)
Kingbase export table structure
High performance current limiter guava ratelimiter
Data collection and management [3]
Seekbar custom pictures are not displayed completely up, down, left, right / bitmaptodrawable / bitmaptodrawable inter rotation / paddingstart/paddingend /thumboffset
Do you feel confused when you study at three in the morning?