Redirects/canonical to latest versions #85

Merged
merged 2 commits into from Dec 17, 2014

Projects

None yet

3 participants

@Ocramius
Member

Link building to documentation is currently broken because docs have the version number of the framework in the url:

  • http://foo/bar/2.0/page.html
  • http://foo/bar/2.1/page.html

While this is great to be able to have documentation relative to the specific version of zf in use, it's also a big problem, because we are basically breaking search results/query on Google.

My solution involves shameless stealing of ideas from the Symfony folks, who did great work on this. They basically redirect the users to a fixed URL for the latest version:

  • http://symfony.com/doc/2.0/book/doctrine.html - stays
  • http://symfony.com/doc/2.1/book/doctrine.html -> redirects to http://symfony.com/doc/current/book/doctrine.html

Also, a warning should be displayed for older doc versions, and a <link rel="canonical" href="..."/> should be rendered, always pointing to the latest version of the page.

This may look like pointless SEO optimization, but if this is not happening soon, searching for docs may become a mess very quickly :)

Ping @Freeaqingme @robertbasic @ezimuel

@froschdesign
Member

@Ocramius
Very good point! 👍

@weierophinney
Member

Anybody want to implement this, by any chance?

We could easily have the Makefile update code inside of rewrites.php whenever we release a new version which would rewrite the latest version to a "current" or "latest" static URL. However, we'd also need to modify (a) routes, and (b) the ManualController to fetch the latest version when "current" or "latest" is matched.

@weierophinney weierophinney self-assigned this Dec 17, 2014
@weierophinney
Member

I'm working on this this morning.

@weierophinney weierophinney [#85] "current" manual version
- Added to "version" constraint the ability to specify "current"
- Injecting Manual PageController with latest version
- Checking if version specified is "current"; if so, using latest
  version
- Checking if version specified is latest version; if so, redirecting to
  "current"
b1fb13f
@Ocramius
Member

@weierophinney awesome, thanks! =)

@froschdesign
Member
@weierophinney weierophinney [#85] Inject canonical rel into manual pages
- If 1.* page, inject link to latest 1.* manual page
- Otherwise, inject link to "current" version
cfb07a4
@weierophinney weierophinney merged commit cfb07a4 into zendframework:master Dec 17, 2014
@weierophinney weierophinney added a commit that referenced this pull request Dec 17, 2014
@weierophinney weierophinney Merge branch 'feature/85'
Close #85
140c8c0
@weierophinney weierophinney added a commit that referenced this pull request Dec 17, 2014
@weierophinney weierophinney Merge branch 'feature/85' into develop
Forward port #85
f5ba12d
@weierophinney weierophinney added a commit that referenced this pull request Dec 17, 2014
@weierophinney weierophinney [#85] Fix manual redirects
- If no version is provided, use 'current'
53a12ff
@weierophinney weierophinney added a commit that referenced this pull request Dec 17, 2014
@weierophinney weierophinney [#85] More rewrite fixes
- Old manual rewrite was a straight regex -- but that regex could match
  "current" as the language. Updated to fix this.
- Also, old manual rewrite did not include a "/" after language!
8187977
@weierophinney weierophinney added a commit that referenced this pull request Dec 17, 2014
@weierophinney weierophinney [#85] Get redirect plugin explicitly
- Was getting 500 errors
0e2dc53
@weierophinney weierophinney added a commit that referenced this pull request Dec 17, 2014
@weierophinney weierophinney [#85] Fixed all redirects 0c6f836
@weierophinney weierophinney added a commit that referenced this pull request Dec 17, 2014
@weierophinney weierophinney [#85] Better selection of most recent 1.x version
- use version_compare on the keys to get the latest 1.x version.
fbd56b0
@weierophinney weierophinney added a commit that referenced this pull request Dec 17, 2014
@weierophinney weierophinney [#85] manuals > 1.9, < 2.0 use "manual.html" as index page
- Added a rewrite rule to fix that, for when the sidebar is used to
  select a version from the "landing page" of any given manual page
f17a650
@weierophinney weierophinney added a commit that referenced this pull request Dec 17, 2014
@weierophinney weierophinney [#85] Updated manual sidebar
- Use "current" as the option for a redirect
674b514
@weierophinney
Member

Okay, this is fully sorted out now -- there were a few glitches with how the "switch version" functionality recently merged worked with this, as well as ensuring that canonical URLs are present for each of ZF1 and ZF2 pages. I think we're in good shape now, though.

Thanks, @Ocramius for the suggestion and the details!

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