Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit a1d03b9

Browse files
authored
Baseline SEO improvements (#2157)
1 parent bcba519 commit a1d03b9

File tree

7 files changed

+30
-25
lines changed

7 files changed

+30
-25
lines changed

nuxt.config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ const meta = [
3131
name: "viewport",
3232
content: "width=device-width,initial-scale=1",
3333
},
34-
// By default, tell all robots not to index pages. Will be overridden in the
34+
// By default, tell all robots not to index pages. Will be overwritten in the
3535
// search, content and home pages.
3636
{ hid: "robots", name: "robots", content: "noindex" },
37-
// Tell Googlebot to crawl Openverse when iframed
38-
// TODO: remove after the iframe is removed
39-
{ hid: "googlebot", name: "googlebot", content: "indexifembedded" },
4037
{
4138
vmid: "monetization",
4239
name: "monetization",
@@ -204,8 +201,10 @@ const config: NuxtConfig = {
204201
],
205202
serverMiddleware: [
206203
{ path: "/healthcheck", handler: "~/server-middleware/healthcheck.js" },
204+
{ path: "/robots.txt", handler: "~/server-middleware/robots.js" },
207205
],
208206
i18n: {
207+
baseUrl: "https://openverse.org",
209208
locales: [
210209
{
211210
// unique identifier for the locale in Vue i18n

src/layouts/content-layout.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ export default defineComponent({
199199
}
200200
},
201201
head() {
202-
return this.$nuxtI18nHead({ addSeoAttributes: true, addDirAttribute: true })
202+
return this.$nuxtI18nHead({
203+
addSeoAttributes: true,
204+
addDirAttribute: true,
205+
})
203206
},
204207
})
205208
</script>

src/layouts/default.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export default defineComponent({
7171
}
7272
},
7373
head() {
74-
return this.$nuxtI18nHead({ addSeoAttributes: true, addDirAttribute: true })
74+
return this.$nuxtI18nHead({
75+
addSeoAttributes: true,
76+
addDirAttribute: true,
77+
})
7578
},
7679
})
7780
</script>

src/pages/search/audio.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ import { useUiStore } from "~/stores/ui"
4949
5050
import { IsSidebarVisibleKey } from "~/types/provides"
5151
52-
import { useFeatureFlagStore } from "~/stores/feature-flag"
53-
5452
import VSnackbar from "~/components/VSnackbar.vue"
5553
import VAudioTrack from "~/components/VAudioTrack/VAudioTrack.vue"
5654
import VLoadMore from "~/components/VLoadMore.vue"
@@ -68,13 +66,8 @@ export default defineComponent({
6866
},
6967
props: propTypes,
7068
setup(props) {
71-
const featureFlagStore = useFeatureFlagStore()
72-
7369
useMeta({
7470
title: `${props.searchTerm} | Openverse`,
75-
meta: featureFlagStore.isOn("new_header")
76-
? [{ hid: "robots", name: "robots", content: "all" }]
77-
: undefined,
7871
})
7972
8073
const uiStore = useUiStore()

src/pages/search/image.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { computed, defineComponent, useMeta } from "@nuxtjs/composition-api"
1212
1313
import { propTypes } from "~/pages/search/search-page.types"
1414
import { useFocusFilters } from "~/composables/use-focus-filters"
15-
import { useFeatureFlagStore } from "~/stores/feature-flag"
1615
1716
import VImageGrid from "~/components/VImageGrid/VImageGrid.vue"
1817
@@ -21,13 +20,8 @@ export default defineComponent({
2120
components: { VImageGrid },
2221
props: propTypes,
2322
setup(props) {
24-
const featureFlagStore = useFeatureFlagStore()
25-
2623
useMeta({
2724
title: `${props.searchTerm} | Openverse`,
28-
meta: featureFlagStore.isOn("new_header")
29-
? [{ hid: "robots", name: "robots", content: "all" }]
30-
: undefined,
3125
})
3226
3327
const results = computed(() => props.resultItems.image)

src/pages/search/index.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { defineComponent, useMeta } from "@nuxtjs/composition-api"
77
88
import { propTypes } from "~/pages/search/search-page.types"
9-
import { useFeatureFlagStore } from "~/stores/feature-flag"
109
1110
import VAllResultsGrid from "~/components/VAllResultsGrid/VAllResultsGrid.vue"
1211
@@ -15,13 +14,8 @@ export default defineComponent({
1514
components: { VAllResultsGrid },
1615
props: propTypes,
1716
setup(props) {
18-
const featureFlagStore = useFeatureFlagStore()
19-
2017
useMeta({
2118
title: `${props.searchTerm} | Openverse`,
22-
meta: featureFlagStore.isOn("new_header")
23-
? [{ hid: "robots", name: "robots", content: "all" }]
24-
: undefined,
2519
})
2620
},
2721
head: {},

src/server-middleware/robots.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { LOCAL, PRODUCTION } = require("../constants/deploy-env")
2+
3+
/**
4+
* Send the correct robots.txt information per-environment.
5+
*/
6+
export default function robots(_, res) {
7+
const deployEnv = process.env.DEPLOYMENT_ENV ?? LOCAL
8+
9+
const contents =
10+
deployEnv === PRODUCTION
11+
? `# This file is intentionally left blank`
12+
: `# Block crawlers from the staging site
13+
User-agent: *
14+
Disallow: /
15+
`
16+
17+
res.setHeader("Content-Type", "text/plain")
18+
res.end(contents)
19+
}

0 commit comments

Comments
 (0)