Using relative paths to link handbook pages

When adding a link to another handbook page, it is best practise to use relative paths. A relative path refers to a location that is relative to a current directory. You can take a look at this video of Jean explaining relative paths and how they work.

To sum up, the path described the location of the file, naming every directory before the file (called .md). Relative paths are a way of indicating where the file is. The program that reads the relative paths interprets links from where it is at the moment, so we need to make sure to indicate if the directory is different to the one we are at the moment.

Example 1: If we are linking the Buddy program handbook page (handbook/people-ops/onboarding/ to the Onboarding for hiring managers page (handbook/people-ops/onboarding/ we will only need to say because they share the same directory. However, if we want to link the Buddy program handbook page to Engineering onboarding page (handbook/engineering/ we would need to use ../ to go back in the directory and then indicate the correct path: ../../engineering/

Example 2: I am on the Code of conduct (handbook/content/company-info-and-process/communication/ I want to link to a specific section of our About Sourcegraph page. I will use the following path: ../about-sourcegraph/ Method:

  • I use one set of ../ to go from the communication folder (where the Code of conduct is) to the company-info-and-process folder (where the About Sourcegraph page is).
  • I add about-sourcegraph/ because that is the file path of the page I want to link to. You can see “index” in the file path when you open or edit the file in GitHub.
  • I add #sourcegraph-open-product-open-company-open-source using a # to indicate the specific section on the page to link to.

Why do we do this? While it is possible to use absolute URLs (ones that include the domain e.g. to link to pages, if the domain changes, it is more difficult to update the URLs compared to using relative URLs.

Remember that if the .md file name changes or the directory changes (because you’ve moved the file to another team’s page, for example) you will need to update the path.