This GitBook Plugin adds "Edit This Page" link on every page.
Link target will be that page's source file on Github or Gitlab or any repo.
- In you gitbook's
book.jsonfile, addedit-linktopluginslist. - In
pluginsConfig, Setbasevalue which is base path to your github or gitlab or other code repo. Trailing slash is NOT required. - By default link label will be "Edit This Page". You can change it using plugin config
label.
{
"plugins": ["edit-link"],
"pluginsConfig": {
"edit-link": {
"base": "https://github.com/USER/REPO/edit/BRANCH/path/to/book",
"label": "Edit This Page"
}
}
}
Note: Above snippet can be used as complete book.json file, if your book doesn't have one yet.
Github/Gitlab: In string ...REPO/edit/BRANCH..., you may replace edit with tree if you want source file to open in read-mode, rather than edit-mode directly on github/gitlab.
- Run
gitbook install. It will automatically installedit-linkgitbook plugin for your book. This is needed only once. - Build your book (
gitbook build) or serve (gitbook serve) as usual.
- If you are not seeing the "Edit this page" link, check if your
book.jsonis valid. You can use this online tool - http://json.parser.online.fr/beta/ - Check if you are using default gitbook theme. It is NOT recommended to modify gitbook themes directly.
This plugin simply looks for HTML comment <!-- Actions Right --> in parsed page content and insert "edit link" HTML just before <!-- Actions Right -->.
This means if that HTML comment changes, this plugin will break but I hope to fix it easily whenever that happen.
