|
| 1 | +## Use reliable links |
| 2 | + |
| 3 | +If you would like to link to a website, |
| 4 | +do your best to link to a reliable link destination, |
| 5 | +sometimes known as a permalink. |
| 6 | + |
| 7 | +Even if you update the link in the repo if it changes or breaks, |
| 8 | +outdated versions might remain in older versions of tools, docs, etc. |
| 9 | +Sometimes the link destination itself can add an appropriate redirect, |
| 10 | +but sometimes it can't and other times it's destination is not the best choice. |
| 11 | + |
| 12 | +- If you're not sure if you need a more reliable link, |
| 13 | + check out [Situations to consider](#situations-to-consider). |
| 14 | +- If your destination does not already have a stable link, |
| 15 | + and you think it would benefit from one, |
| 16 | + follow the instructions in [Create a reliable link](#create-a-reliable-link). |
| 17 | + |
| 18 | +### Situations to consider |
| 19 | + |
| 20 | +There are many linking situations that could benefit from a more |
| 21 | +stable/reliable redirect with a memorable URL. |
| 22 | +For reference, the following are a few situations where |
| 23 | +they can have a high impact: |
| 24 | + |
| 25 | +- Output from CLI tools like `flutter` and `dart` |
| 26 | +- Comments or prose in files generated by tools like `flutter create` |
| 27 | +- API docs in the framework or other bundled packages |
| 28 | +- Error messages and other diagnostics from the engine, framework, or |
| 29 | + other Flutter-team maintained packages |
| 30 | +- Troubleshooting links from DevTools and editors |
| 31 | + |
| 32 | +> [!TIP] |
| 33 | +> Links that would lead to fragments on the Dart and Flutter sites |
| 34 | +> should often be replaced with a custom reliable link. |
| 35 | +> Browsers don't send URI fragments to the server, |
| 36 | +> so redirecting them needs extra client-side handling. |
| 37 | +
|
| 38 | + |
| 39 | +### Create a reliable link |
| 40 | + |
| 41 | +If you need a reliable link, consider |
| 42 | +adding a tooling redirect to the Flutter documentation site, |
| 43 | +and using that in place of the intended destination. |
| 44 | +Tooling redirects are added in a similar fashion to design-doc go links, |
| 45 | +and the website team will do their best to keep it functional. |
| 46 | +Once created, a tooling redirect is accessed through a link like |
| 47 | +starting with `/to/`, such as `flutter.dev/to/gesture-disambiguation`. |
| 48 | + |
| 49 | +Before creating a new tooling link, |
| 50 | +verify that an appropriate one doesn't exist already. |
| 51 | +To see what redirects exist already, check the `/to/` entries in |
| 52 | +[`flutter/website/firebase.json`][flutter-redirects] and |
| 53 | +[`dart-lang/site-www/firebase.json`][dart-redirects]. |
| 54 | + |
| 55 | +If an appropriate tooling redirect doesn't exist already, |
| 56 | +create one following these steps: |
| 57 | + |
| 58 | + 1. Open the [`firebase.json` file][flutter-redirects] in the |
| 59 | + `flutter/website` repository and edit it using the GitHub UI or locally. |
| 60 | + 2. Determine a short, relevant, and memorable name for the redirect. |
| 61 | + No special characters are allowed and under 5 words is preferred. |
| 62 | + Remember users might need to type it manually, or it might be output |
| 63 | + in a crowded terminal or UI. |
| 64 | + 3. Convert the name to a `lowercase-with-dashes` format and fill out |
| 65 | + a redirect entry in the following format with it and the destination URL: |
| 66 | + |
| 67 | + ```json |
| 68 | + { "source": "/to/<redirect-name>", "destination": "<url>", "type": 301 } |
| 69 | + ``` |
| 70 | + |
| 71 | + Note that if you are linking to the Flutter docs site itself, |
| 72 | + don't include the origin of the destination URL, just the path. |
| 73 | + 4. Place this entry with the other tooling (`/to/`) redirects in the file |
| 74 | + according to its alphanumerical sorting. |
| 75 | + Certain editors can sort a selected portion of the redirects as well. |
| 76 | + 5. Commit your changes, push them if needed, and open a new pull request |
| 77 | + against the `flutter/website` repository's `main` branch. |
| 78 | + 6. Set a descriptive pull request title, similar to the following: |
| 79 | + |
| 80 | + ```markdown |
| 81 | + Add a `/to/<redirect-name>` tooling redirect |
| 82 | + ``` |
| 83 | + 7. In the pull request description, include a link to the PR, CL, or |
| 84 | + wherever else that will make use of the redirect, as well as |
| 85 | + what project team can be reached out to if it needs to be updated. |
| 86 | + 8. Unless a website maintainer has feedback about the |
| 87 | + redirect name, usefulness, destination, or formatting, |
| 88 | + they will approve and land the change for you. |
| 89 | + 9. Once your tooling redirect has landed, |
| 90 | + switch to using the tooling redirect wherever needed. |
| 91 | +10. The website maintainers might reach out to you |
| 92 | + if the redirect needs to be updated, but do consider |
| 93 | + checking your redirects occasionally to verify they still make sense. |
| 94 | + |
| 95 | +> [!IMPORTANT] |
| 96 | +> There is a maintenance cost of a tooling redirect, |
| 97 | +> both for your team and the website maintainers. |
| 98 | +> |
| 99 | +> So if the link is being surfaced in a way or location |
| 100 | +> that users will quickly see an updated version, |
| 101 | +> a tooling redirect might not be necessary. |
| 102 | +> The same goes for links that are only needed for a short time. |
| 103 | + |
| 104 | +[flutter-redirects]: https://github.com/flutter/website/blob/main/firebase.json |
| 105 | +[dart-redirects]: https://github.com/dart-lang/site-www/blob/main/firebase.json |
0 commit comments