当前位置: 首页 > news >正文

永兴县网站建设公司成立做网站的公司

永兴县网站建设公司,成立做网站的公司,怎么上传自己的网站,前端网页设计用什么软件1 SiteMap设置 环境准备 注意生成sitemap依赖于nuxtjs/sitemap,并且需要用axios进行请求,不要使用nuxtjs/axios,不然会报错 sitemap.xml配置 在nuxt.config.js中配置下面的内容 npm install nuxtjs/sitemap npm install axios在static/s…

1 SiteMap设置

环境准备

注意生成sitemap依赖于@nuxtjs/sitemap,并且需要用axios进行请求,不要使用@nuxtjs/axios,不然会报错

sitemap.xml配置
  • 在nuxt.config.js中配置下面的内容
npm install @nuxtjs/sitemap
npm install axios
  • 在static/sitemap.js中配置下面的内容
const webConfig = {// 本地local: {baseURL: 'http://localhost:8828',referer: 'http://localhost:8828/',url: 'http://localhost:8828'},// sit环境sit: {baseURL: '',referer: '',url: ''},// 线上环境production: {baseURL: '',referer: '/',url: ''}
}import axios from 'axios'
// 运行环境是不是开发环境
const isDev = Boolean(process.env.OPE_ENV === 'development')
const API_ENV = process.env.API_ENV
// 接口url
const baseUrl = webConfig[API_ENV].baseURL
// referer
const referer = isDev ? webConfig['local'].referer : webConfig[API_ENV].referer
// 网站域名
const hostname = isDev ? webConfig['local'].url : webConfig[API_ENV].urlconst config = {baseURL: baseUrl,withCredentials: true,time: Date.now(),headers: {Accept: 'application/json; charset=utf-8',Referer: referer,common: {languageCode: 'zh-CN',referer: referer}}
}
const sitemap = {path: '/sitemap.xml', //生成的文件路径hostname: hostname, //网站的网址cacheTime: 1000 * 60 * 60 * 24, //一天的更新频率,只在generate:false有用gzip: true, //生成.xml.gz的sitemapgenerate: false,// 排除不要页面exclude: ['/404','/page','/details','/article','/tags','/category','/search'],defaults: {changefred: 'always',lastmod: new Date(),priority: 0.8},routes: async () => {let routes = []let res = await axios.get(`${baseUrl}/api/getArticle`, {})if (res.code === 200) {res.list.forEach((item) => {routes.push({url: `/xxxx/${item.pageCode}`,changefreq: 'always',priority: 0.9})})}return routes}
}
module.exports = sitemap
  • 在nuxt.config.js中配置下面的内容
const sitemap = require('./static/sitemap')module.exports = {...,sitemap: sitemap,
}

2 robots.txt协议

在nuxt项目的static文件夹下,配置项目的静态文件,直接在static新建robots.txt即可,nuxt运行时会自动装配到根路由

# 该文件可以通过`网站域名/Robots.txt`直接访问# User-agent作用:描述搜索引擎的名字,对于该文件来说至少药有一条user-agent记录,则该项的值设为*
User-agent: *
# Disallow:  描述不希望被访问到的一个url
Disallow: /cart?*
Disallow: /*Cart-*
Disallow: /*retailavailability
Allow: /*wishlist*.js
Sitemap: 网站的域名/sitemap.xml

3 seo优化

  • 全局seo:在nuxt.config.js的meta中添加网站的字符编码、语言、响应式标签、网站描述、网站关键字等信息;在link中添加全局的css、网站logo等信息。
head: {title: pkg.name,meta: [{ charset: 'utf-8' },{ name: 'viewport', content: 'width=device-width, initial-scale=1' },{ hid: 'description', name: 'description', content: pkg.description }],link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]},
  • 页面seo:在nuxt.js项目pages路由页面的script中添加head方法,该方法将随nuxt运行时自动载入
head () {return {title: `${this.info.blogName} | ${this.info.blogDescription}`,meta: [{ name: 'keywords', content: this.info.keywords },{ name: 'description', content: this.info.description }]}
}
http://www.yayakq.cn/news/300895/

相关文章:

  • 申请域名流程后怎样做网站晋中市建设局网站
  • 用vps建网站备案做网站一个月20g流量够吗
  • 网站推广页建设招标网官方网站
  • eclipse网站开发流程图胶州专业网站建设公司
  • 网站名称设置国内精自品线一区91制片
  • 郑州网站建设信息做网站 怎么推广
  • 深圳网站建设公司服务苏州建网站的公司外包服务
  • 以前自己做的网站怎么样删除网站开发公司小程序开发
  • 潮州市工程建设网站温州设计网站建设
  • 长沙网站设计多少钱一个月seo网络优化平台
  • 怎么做弹幕网站营销型网站有意义吗
  • 商城网站的建设定位昆明最新消息今天
  • 网站推广费用ihanshi网站新版
  • 郑州做品牌网站的公司建立一个网站需要什么
  • 网站业务员怎么给客户做方案网站建设是广告吗
  • 网站投稿源码中山建设安监站网站
  • 网站开发的设计与实现重庆网站免费优化
  • 网站建设ppt方案结语如何进行搜索引擎优化
  • 局网站建设意见农产品网站建设
  • 建设优秀企业网站温州鹿城区企业网站搭建
  • 友情链接的网站电子商务网站制作公司
  • 网站公司的利润在哪里经典的企业网站
  • 单位的网站的建设方案天津vi设计公司
  • c2c电子商务网站用到的技术网站建设维护和服务合同
  • 网站开发个人简历word下载页面设计培训排名
  • 成都网站设公司奉贤区网站建设
  • 营销型网站效果android安卓版下载
  • 作品集模板网站新媒体营销和网络营销
  • 怎么做外网网站监控软件windows优化大师有什么功能
  • 网站建设感悟西安网站建设招骋