[dw-free] Arguments cause a page to be indexed as different content on search engines
[commit: http://hg.dwscoalition.org/dw-free/rev/e36c136e204d]
http://bugs.dwscoalition.org/show_bug.cgi?id=1427
Add canonical links in page headers on entries.
Patch by
afuna.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1427
Add canonical links in page headers on entries.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/S2/EntryPage.pm
- cgi-bin/LJ/S2/ReplyPage.pm
- htdocs/talkpost.bml
- htdocs/talkread.bml
-------------------------------------------------------------------------------- diff -r 4997039fd165 -r e36c136e204d cgi-bin/LJ/S2/EntryPage.pm --- a/cgi-bin/LJ/S2/EntryPage.pm Thu Jul 16 19:12:47 2009 -0500 +++ b/cgi-bin/LJ/S2/EntryPage.pm Thu Jul 16 21:46:29 2009 -0500 @@ -54,6 +54,11 @@ sub EntryPage my $next_url = S2::Builtin::LJ::Entry__get_link( $opts->{ctx}, $s2entry, "nav_next" )->{url}; $p->{head_content} .= qq{<link rel="next" href="$next_url" />\n} if $next_url; + + # canonical link to the entry or comment thread + my $canonical_url = $permalink; + $canonical_url .= "?thread=$get->{thread}#t$get->{thread}" if $get->{thread}; + $p->{head_content} .= qq{<link rel="canonical" href="$canonical_url" />\n}; # quickreply js libs LJ::need_res(qw( diff -r 4997039fd165 -r e36c136e204d cgi-bin/LJ/S2/ReplyPage.pm --- a/cgi-bin/LJ/S2/ReplyPage.pm Thu Jul 16 19:12:47 2009 -0500 +++ b/cgi-bin/LJ/S2/ReplyPage.pm Thu Jul 16 21:46:29 2009 -0500 @@ -42,6 +42,12 @@ sub ReplyPage return if $opts->{'handler_return'}; return if $opts->{'redir'}; my $ditemid = $entry->ditemid; + + # canonical link to the entry or comment thread + my $canonical_url = $entry->url; + $canonical_url .= "?thread=$get->{replyto}#t$get->{replyto}" if $get->{replyto}; + $p->{head_content} .= qq{<link rel="canonical" href="$canonical_url" />\n}; + $p->{'head_content'} .= $LJ::COMMON_CODE{'chalresp_js'}; LJ::need_res('stc/display_none.css'); diff -r 4997039fd165 -r e36c136e204d htdocs/talkpost.bml --- a/htdocs/talkpost.bml Thu Jul 16 19:12:47 2009 -0500 +++ b/htdocs/talkpost.bml Thu Jul 16 21:46:29 2009 -0500 @@ -132,6 +132,11 @@ body<= my $ditemid = $init->{'ditemid'}; my $talkurl = LJ::journal_base($u) . "/$ditemid.html"; my $entry = LJ::Entry->new($u, ditemid => $ditemid); + + # canonical link to the entry or comment thread + my $canonical_url = $entry->url; + $canonical_url .= "?thread=$GET{replyto}#t$GET{replyto}" if $GET{replyto}; + $head .= qq{<link rel="canonical" href="$canonical_url" />\n}; $parpost ||= $item; # if there's no parent post, remote is reply to top-level item diff -r 4997039fd165 -r e36c136e204d htdocs/talkread.bml --- a/htdocs/talkread.bml Thu Jul 16 19:12:47 2009 -0500 +++ b/htdocs/talkread.bml Thu Jul 16 21:46:29 2009 -0500 @@ -113,6 +113,11 @@ body<= } my $entry = LJ::Entry->new($u, ditemid => $ditemid); + + # canonical link to the entry or comment thread + my $canonical_url = $entry->url; + $canonical_url .= "?thread=$GET{thread}#t$GET{thread}" if $GET{thread}; + $$head .= qq{<link rel="canonical" href="$canonical_url" />\n}; $u->preload_props("opt_blockrobots", "adult_content") if $u->is_visible; if (!$u->is_visible || $u->should_block_robots || ($entry && $entry->should_block_robots)) { --------------------------------------------------------------------------------