This is not a question about best practice within SEO but a question about how to setup config.js and script sections correctly in VUE
I have build my site with Vue/Nuxt and what have earlier been a walk in the park for me with angular, are now causing errors.
My overall problem is that I am not sure if I have build my script section right as my pages are not getting indexed by Google. In my nuxt.config.js file I have build my sitemap, robot.txt and some general meta-tags. For every page I have build dynamic meta tags in their script section.
Google Search Console is giving 3 type of errors.
Some pages are blocked by my robot.txt
Some pages is said to be dublicated rel-canonical
When inspecting my site it cant fint pages without typing in '/' at the end of the URL. This is also seen when using Screaming Frog SEO tool.
My assumption is that I am missing some form of a redirect that makes the crawler index pages ending with '/' as those are getting indexed fine in Search Console?
Nuxt.config.js file (Sections, not all content is showed)
head: {
title: 'NorthArc',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ name: 'language', content: 'da_DK' },
{ name: 'robots', content: 'index, follow' },
{ name: 'og:type', content: 'website' },
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
]
},
sitemap: {
path: '/sitemap.xml',
hostname: 'https://northarc.dk/',
routes: [
{
url: '/',
changefreq: 'monthly',
priority: 1,
},
{
url: '/team/',
changefreq: 'monthly',
priority: 1,
},
{
url: '/groen-planlaegning/',
changefreq: 'monthly',
priority: 1,
},
{
url: '/strategisk-samarbejde/',
changefreq: 'monthly',
priority: 1,
},
{
url: '/blog/',
changefreq: 'monthly',
priority: 1,
},
{
url: '/blog/er-ruteplanlaegning-svaert/',
changefreq: 'monthly',
priority: 1,
},
{
url: '/blog/automatisk-ruteplanlaegning/',
changefreq: 'monthly',
priority: 1,
},
{
url: '/faq/',
changefreq: 'monthly',
priority: 1,
},
{
url: '/contact/',
changefreq: 'monthly',
priority: 1,
},
{
url: '/policies/',
changefreq: 'monthly',
priority: 1,
}
]
},
robots: {
UserAgent: 'Googlebot',
Disallow: ['/roi', '/pricing'],
Sitemap: 'https://northarc.dk/sitemap.xml',
},
Script section from a page that is said to be blocked bt robot.txt and has dublicated rel-canonical.
<script>
export default {
name: 'home',
head() {
return {
title: 'test',
meta: [
{
hid: 'description',
name: 'description',
content: 'test',
},
{ hid: 'robots', name: 'robots', content: 'index, follow' },
{hid: 'og-title', property: 'og:title', content: 'Fjern spildtid på vejen og minimere antal kørte kilometer'},
{hid: 'og-url', property: 'og:url', content: 'https://northarc.dk/groen-planlaegning'},
{hid: 'og-description', property: 'og:description', content: 'test'},
{hid: 'og-image', property: 'og:image', content: '/Applications/Northarc_landing/assets/Preview_sløret.jpg'},
],
link: [
{
rel: 'canonical',
href: 'https://northarc.dk/groen-planlaegning/'
}
]
}
}
};
</script>
Notes: (change-log)
I have tried to add a '/' to all sites URL in my sitemap and at the rel-canonical for the pages example showed above.
I have tried to change the user of robot.txt to googlebot to disallow two pages. Before the user was set to '*' where it still blocked some pages.
By default Nuxt allows each route without or with a trailing slash, example:
https://northarc.dk/blog
https://northarc.dk/blog/
It can be detect as duplicate content by crawlers.
So you can define which is the main URL with the "canonical" header.
But if you want keep URLs only with a trailing slash at end, you have to allow only route with a trailing slash by the router configuration:
// nuxt.config.js
router: {
trailingSlash: true
}
See docs https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-router#trailingslash
in addition,
you don't need to hardcoded all your routes in the sitemap-module config, it's automatic for all static routes, eg.:
// nuxt.config.js
sitemap: {
hostname: 'https://northarc.dk',
defaults: {
changefreq: 'monthly',
priority: 1,
trailingSlash: true
},
exclude: ['roi', 'pricing'],
trailingSlash: true // if necessary
},
Related
Why doesn't the local configuration for meta title and description override the global configuration
The problem is that when I change the meta tags and links on the page, it removes the meta tags that are global and replaces the new meta tags. I want these meta and links to be added to the global meta and links.
In the meta tag and global links that I have, I have a part that makes the logo part of the site correct when adding a bookmark in Safari, but when I add the meta tag to my page, the photo is no longer loaded, and I think the problem is from It is that Next replaces the meta tags that are created on each page instead of the global meta tags
Code
**this is my nuxt config code**
head: {
title: 'Flyver',
htmlAttrs: {
lang: 'en',
},
meta: [
.........
{ charset: 'utf-8' },
{
name: 'viewport',
hid: 'viewport',
content:
'width=device-width,initial-scale=1,shrink-to-fit=no,maximum-scale=5,viewport-fit=cover',
},
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' },
{
hid: 'apple-mobile-web-app-status-bar-style',
name: 'apple-mobile-web-app-status-bar-style',
content: 'black-translucent',
},
.........
],
link: [
.........
{
hid: 'apple-touch-icon',
rel: 'apple-touch-icon',
href: '/android-chrome-180x180.png?v=sf54fgh123',
type: 'image/png',
sizes: '180x180',
},
{
hid: 'apple-touch-icon1',
rel: 'apple-touch-icon',
href: '/apple-touch-icon.png?v=sf54fgh123',
type: 'image/png',
sizes: '120x120',
},
.........
},
this is my index page**
async fetch() {
........
this.headValue = {
title: this.pageData?.value?.title,
link: [
{
rel: 'canonical',
href: `https://flyver.ir`,
},
],
meta: [
{
name: 'description',
content: this.pageData?.value?.description,
},
...this.pageData?.metaTags,
],
};
..........
},
head() {
return this.headValue;
},
What is Expected?
I expect the meta tags that are created per page to be added to the global meta tags
What is actually happening?
Replaces new meta tags with global meta tags
I don't understand why my app has meta robots set to noindex when I'm in production mode only ??
Here is my nuxt.config
import i18n from './config/i18n'
export default {
head: {
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ hid: 'robots', name: 'robots', content: 'index, follow' }
],
},
buildModules: ['nuxt-lazysizes',
[
'nuxt-i18n',
{
strategy: 'prefix_except_default',
defaultLocale: 'en',
seo: true,
baseUrl: envBaseUrl,
locales: [
{
code: 'en',
name: 'English',
iso: 'en-GB'
},
{
code: 'fr',
name: 'Français',
iso: 'fr-FR'
}
],
vueI18n: i18n
}
]
],
env: {
baseUrl: envBaseUrlAdmin
},
}
I even set the meta in the layout /default.vue just in case, but still the same.
This is driving me insane !!
It's perfectly fine in dev mode. Why would any one want production with no index and dev or staging with it ? This is absurd.
head () {
return {
meta: [{ hid: 'robots', name: 'robots', content: 'index, follow' }],
}
}
Ok, it was a conflict with my Yoast plugin. Haven't found why it was only doing this in prod, and not in dev, but it's fine now. Sorry for the dumb question.
I recently started using ** Docusaurus2 ** for tech notes in college.
I am interested in creating one or more Docs2, Docs3.
I have seen that it is a pluging that has to be duplicated. But with my config, it doesn't generate index.html for additionals tabs.
This is my folder list for docs: docs, dev. And in the dev folder some markdown files.
My docusaurus.config.js is:
module.exports = {
title: 'ApuntEs',
tagline: 'The tagline of my site',
url: 'https://your-docusaurus-test-site.com',
baseUrl: '/',
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
favicon: 'img/favicon.ico',
organizationName: 'srlopez', // Usually your GitHub org/user name.
projectName: 'apuntes', // Usually your repo name.
themeConfig: {
navbar: {
title: 'ApuntEs',
logo: {
alt: 'ApuntEs',
src: 'img/logo.svg',
},
items: [
{
to: 'docs/',
activeBasePath: 'docs',
label: 'Docs',
position: 'left',
},
{to: 'dev/', activeBasePath: 'dev', label: 'Dev', position: 'left'},
{to: 'blog', label: 'Blog', position: 'left'},
{
href: 'https://github.com/facebook/docusaurus',
label: 'GitHub',
position: 'right',
},
],
},
footer: {
// omited
},
},
presets: [
[
'#docusaurus/preset-classic',
{
docs: {
id: 'doc',
sidebarPath: require.resolve('./sidebars.js'),
},
blog: {
showReadingTime: true,
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
},
],
],
plugins: [
[
"#docusaurus/plugin-content-docs",
{
id: 'dev',
path: "dev", // Path to data on filesystem, relative to site dir.
routeBasePath: "dev", // URL Route.
include: ["**/*.md"],
sidebarPath: require.resolve('./sidebarsDev.js'),
},
],
],
};
It looks nice, but tab Dev doesn't work. The index.html is not generated on npx docusaurus build
and this is the version I am using.
npx docusaurus --version
2.0.0-alpha.70
May some one help me?
I have a Manifest with stuff like name etc. which also instantly brings out meta tags for my page. Now I wanna use Meta Tags on my individual Pages, the problem is that the Manifest Meta Tags dont get overwritten which leads to them having higher priority for sites like Facebook etc.
Example Manifest:
manifest: {
theme_color: '#1a1a1a',
name: 'Stackoverflow',
short_name: 'SO',
description: 'Questions and Answers',
lang: 'de'
},
Example change in the Page:
head () {
return {
meta: [
{ name: 'og:url', content: 'www.notstackoverflow.com' },
{ name: 'og:type', content: 'article' },
{ name: 'og:title', content: this.post.titel },
{ name: 'og:description', content: this.post.subtitel },
]
}
},
The problem is that it still uses the title and description from the manifest instead of the page. It only adds the ones from the page after the manifest ones if I go on View Source.
(Nuxt + PWA Module)
you must add the hid property for each meta:
head () {
return {
meta: [
{ hid: 'og:url', name: 'og:url', content: 'www.notstackoverflow.com' },
{ hid: 'og:type', name: 'og:type', content: 'article' },
{ hid: 'og:title', name: 'og:title', content: this.post.titel },
{ hid: 'og:description', name: 'og:description', content: this.post.subtitel },
]
}
},
see https://nuxtjs.org/faq/duplicated-meta-tags
To avoid any duplication when used in child component, please give a unique identifier with the "hid" key.
I am looking for ways to refactor this:
nuxt.config.js
const headConfig = require('./config/head')
const modulesConfig = require('./config/modules')
const config = {
head: headConfig,
(...)
}
module.exports = Object.assign({}, config, modulesConfig)
config/head.js
module.exports = {
meta: [
{charset: 'utf-8'},
{name: 'viewport', content: 'width=device-width, initial-scale=1'},
{name: 'fb:app_id', content: 'xxxx'},
{hid: 'og:url', name: 'og:url', content: 'xxxx'},
{hid: 'og:type', name: 'og:type', content: 'website'},
{hid: 'og:image', name: 'og:image', content: 'xxxx'},
{hid: 'og:site_name', name: 'og:site_name', content: 'xxxx'},
{hid: 'keywords', name: 'keywords', content: 'xxxx'}
]
}
An example of what I'd like to be able to do is to automatically set the 'og:url' to the url of the page. There is no need to repeat that every time.
At the moment I include this in each page of my Nuxt.js app:
{
hid: 'og:url',
property: 'og:url',
content: 'https://website.com' + this.$route.fullPath
},
I am sure there is a better way to automatically set that somewhere :/
Probably your best bet would be to create a global Mixin:
https://v2.vuejs.org/v2/guide/mixins.html#Global-Mixin
This should allow you to create a head mixin that will be auto-imported into every component, so you could define that og:url once and have it auto-injected everywhere.
Here's an example of how you'd register it as a plugin with Nuxt:
/plugins/headMixin.js
import Vue from 'vue'
export default ({ route }) => {
Vue.mixin({
head() {
return {
meta: [
{
hid: `og:url`,
property: 'og:url',
content: 'https://www.yoursite.com' + route.fullPath
}
]
}
}
})
}
in nuxt.config.js:
plugins: [
'~/plugins/headMixin.js'
]
this is my way
in nuxt.config.js:
head: {
title: 'default title',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: 'default description'
}
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
in default.vue
export default {
head() {
return {
title: `Company - ${this.$route.meta.title}`,
meta: [
{
hid: 'description',
name: 'description',
content: this.$route.meta.description
}
],
}
},
and if you use #nuxtjs/router in router.js
routes: [
{
path: '/page',
name: 'some',
meta: {
title: 'Best seo title',
description: 'Best seo description'
},
component: someComponent,
},
All the data you write in routes. Everything works perfectly.