Skip to content

Instantly share code, notes, and snippets.

@antony
Created October 22, 2018 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antony/c66327ee9293f74abbeeb8d2e3b1f639 to your computer and use it in GitHub Desktop.
Save antony/c66327ee9293f74abbeeb8d2e3b1f639 to your computer and use it in GitHub Desktop.
Simple robots.txt generation for Sapper
{
UserAgent: '*',
Disallow: '/'
}
// Lives in routes/robots.txt.js
const robots = process.env.robotsTxt
export function get (req, res) {
res.setHeader('Content-Type', 'text/plain')
const content = Object.keys(robots)
.reduce((acc, next) => {
return acc += `${next}: ${robots[next]}\n`
}, '')
res.end(content)
}
@multipliedtwice
Copy link

can we simply create file /static/robots.txt ?

@antony
Copy link
Author

antony commented Jul 14, 2023

if you don't have any dynamic content in it, yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment