Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
feat(SEO): allow Browsershots, disallow /thanks in robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
CanRau committed Oct 6, 2018
1 parent 962fcb8 commit 8db3280
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,15 @@ exports.onPostBuild = () => {
}

// add robots.txt to site root depending on $BRANCH env var
const robotsTxt = `User-agent: *\nDisallow:${isMaster ? `` : ` /`}`
console.log(`$BRANCH`, BRANCH, isMaster, robotsTxt)
writeFileSync(join(publicDir, `robots.txt`), robotsTxt)
const robotsTxt = []
if (isMaster) {
robotsTxt.push(`User-agent: *\nDisallow:`)
} else {
robotsTxt.push(`User-agent: *\nDisallow: /`)
}
robotsTxt.push(`User-agent: *\nDisallow: /de/danke\nDisallow: /en/thanks`)
robotsTxt.push(`User-agent: Browsershots\nDisallow:`)
writeFileSync(join(publicDir, `robots.txt`), robotsTxt.join(`\n\n`))
}

/**
Expand Down

0 comments on commit 8db3280

Please sign in to comment.