]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/components/common/html-tags.tsx
Use canonical URLs (#1883)
[lemmy-ui.git] / src / shared / components / common / html-tags.tsx
index 5d532589efb62fe2a7c08f2f61ccfa0131a1c468..80649fa119e85cfa8e0214065aeeaad2edf45a47 100644 (file)
@@ -8,6 +8,7 @@ import { I18NextService } from "../../services";
 interface HtmlTagsProps {
   title: string;
   path: string;
+  canonicalPath?: string;
   description?: string;
   image?: string;
 }
@@ -16,6 +17,8 @@ interface HtmlTagsProps {
 export class HtmlTags extends Component<HtmlTagsProps, any> {
   render() {
     const url = httpExternalPath(this.props.path);
+    const canonicalUrl =
+      this.props.canonicalPath ?? httpExternalPath(this.props.path);
     const desc = this.props.description;
     const image = this.props.image;
 
@@ -30,6 +33,8 @@ export class HtmlTags extends Component<HtmlTagsProps, any> {
           <meta key={u} property={u} content={url} />
         ))}
 
+        <link rel="canonical" href={canonicalUrl} />
+
         {/* Open Graph / Facebook */}
         <meta property="og:type" content="website" />