Skip to content

Add canonical links for documentation pages#329

Open
danielh-official wants to merge 1 commit intoNativePHP:mainfrom
danielh-official:set-canonical-links-for-documentation-pages
Open

Add canonical links for documentation pages#329
danielh-official wants to merge 1 commit intoNativePHP:mainfrom
danielh-official:set-canonical-links-for-documentation-pages

Conversation

@danielh-official
Copy link
Copy Markdown
Contributor

Search engines and AI (like Google Gemini) usually apply a larger weight to content based on how long it's been around.

This can mean that old and deprecated documentation can be pushed to the forefront when a developer searches for an answer on how to do XYZ with NativePHP (especially if he or she doesn't specify the version number of the documentation).

Adding a canonical link to the head of each documentation page informs the search engine of the latest version of that page to use, pushing its content to the forefront, regardless of how long it's been around.

For reference, Laravel documentation inserts a canonical link for its pages.

e.g., https://laravel.com/docs/13.x/starter-kits has <link rel="canonical" href="https://laravel.com/docs/13.x/starter-kits" data-inertia="canonical">

This change adds canonical links for each version of each documentation page, pointing to the latest version of that page.

e.g., https://nativephp.com/docs/mobile/2/getting-started/introduction would have a canonical link like so: <link rel="canonical" href="https://nativephp.com/docs/mobile/3/getting-started/introduction">

The idea is that the LLM crawler would see the canonical link and know to use the content for version 3 of that page if a developer doesn't explicitly state he or she wants version 1 or 2 of the documentation.

Some Exceptions

If the latest version of that page doesn't exist, it resolves to the latest version of the home documentation page, which is getting-started/introduction for both platforms.

Also, if on the v1 or v2 versions of the "APIs" pages for the mobile platform, the canonical link resolves them to the "plugins/core" of the latest version.

This logic is taken from the resources/views/components/docs/old-version-notice.blade.php file.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant