Step 6: Add Your First Plugin
This step uses @shevky/plugin-robots-txt because it is simple and easy to verify.
Prerequisites
- A working Shevky project with
src/site.json
Commands
Install the plugin (if not already installed):
npm install @shevky/plugin-robots-txtEnsure it is listed in src/site.json:
"plugins": [
"@shevky/plugin-robots-txt"
]Add robots configuration:
"robots": {
"allow": ["/"],
"disallow": ["/draft/"]
}Build and verify:
npm run build
cat dist/robots.txtExpected Output
dist/robots.txt should contain:
User-agent: *
Allow: /
Disallow: /draft/
Sitemap: https://yourdomain.com/sitemap.xmlWhat Just Happened
- The plugin was discovered via the
pluginsarray insite.json. PluginRegistry.load()dynamically imported the plugin package.- During the
dist:cleanhook, the plugin readconfig.identity.urlandconfig.robotsvalues. - It generated a
robots.txtfile and wrote it todist/.
Common Errors
| Error | Fix |
|---|---|
| Plugin not running | Verify the exact package name @shevky/plugin-robots-txt in plugins[] |
| Wrong sitemap URL | Set identity.url correctly and rebuild |
dist/robots.txt missing | Check build logs for plugin load errors |