- Added branch graph image servlet based on EGit's branch graph renderer (issue-194)
- Added option to render Markdown commit messages (issue-203)
- Added setting to control creating a repository as --shared on Unix servers (issue-263)
+ - Set Link: <url>; rel="canonical" http header for SEO (issue-304)
- Added raw links to the commit, commitdiff, and compare pages (issue-319)
- Support intradocument linking in Markdown content using [[WikiLinks]] syntax (issue-324)
- Added setting to globally disable anonymous pushes in the receive pack
}\r
}\r
\r
+ protected String getCanonicalUrl() {\r
+ return getCanonicalUrl(getClass(), getPageParameters());\r
+ }\r
+\r
+ protected String getCanonicalUrl(Class<? extends BasePage> clazz, PageParameters params) {\r
+ String relativeUrl = urlFor(clazz, params).toString();\r
+ String canonicalUrl = RequestUtils.toAbsolutePath(relativeUrl);\r
+ return canonicalUrl;\r
+ }\r
+\r
protected String getLanguageCode() {\r
return GitBlitWebSession.get().getLocale().getLanguage();\r
}\r
\r
@Override\r
protected void setHeaders(WebResponse response) {\r
+ // set canonical link as http header for SEO (issue-304)\r
+ // https://support.google.com/webmasters/answer/139394?hl=en\r
+ response.setHeader("Link" ,MessageFormat.format("<{0}>; rel=\"canonical\"", getCanonicalUrl()));\r
int expires = GitBlit.getInteger(Keys.web.pageCacheExpires, 0);\r
if (expires > 0) {\r
// pages are personalized for the authenticated user so they must be\r
import org.apache.wicket.markup.html.panel.Fragment;\r
import org.apache.wicket.model.IModel;\r
import org.apache.wicket.model.Model;\r
-import org.apache.wicket.protocol.http.RequestUtils;\r
import org.apache.wicket.request.target.basic.RedirectRequestTarget;\r
import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
import org.eclipse.jgit.lib.PersonIdent;\r
String searchString = searchBoxModel.getObject();\r
if (StringUtils.isEmpty(searchString)) {\r
// redirect to self to avoid wicket page update bug\r
- PageParameters params = RepositoryPage.this.getPageParameters();\r
- String relativeUrl = urlFor(RepositoryPage.this.getClass(), params).toString();\r
- String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);\r
+ String absoluteUrl = getCanonicalUrl();\r
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));\r
return;\r
}\r
// use an absolute url to workaround Wicket-Tomcat problems with\r
// mounted url parameters (issue-111)\r
PageParameters params = WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType);\r
- String relativeUrl = urlFor(searchPageClass, params).toString();\r
- String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);\r
+ String absoluteUrl = getCanonicalUrl(searchPageClass, params);\r
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));\r
}\r
}\r