# I want to Update rel=canonical href using Java Script

**URL:** https://meta.discourse.org/t/i-want-to-update-rel-canonical-href-using-java-script/159527
**Category:** Support
**Created:** [August 1, 2020, 4:00pm UTC](https://meta.discourse.org/t/i-want-to-update-rel-canonical-href-using-java-script/159527 "2020-08-01T16:00:23Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [August 2, 2020, 7:47am UTC](https://meta.discourse.org/t/i-want-to-update-rel-canonical-href-using-java-script/159527/13 "2020-08-02T07:47:37Z")

</div>

I’m not sure if overriding canonical using Javascript will work since this is something that is more on the spider level (i.e. the part that retrieves and collects data) than on the indexer level (the part of a bot that interprets data and stores it in the search index).

> [@neounix](#):
>
> modify this Discourse Ruby lib file directly

Unsolicited advice: you might want to read this topic so you can put those overrides in a plugin:

> [@Override existing Discourse methods in plugins](https://meta.discourse.org/t/tips-for-overriding-existing-discourse-methods-in-plugins/83389):
>
> I’ve been running into a bunch of instances recently of needing to override existing ruby methods from plugins, and thought I’d share my best practices here. Overriding an instance method class ::TopicQuery module BabbleDefaultResults def default\_results(options={}) super(options).where('archetype \<\> ?', Archetype.chat) end end prepend BabbleDefaultResults end Here I’m removing chat topics from an instance method which is returning a list of topics. The module name BabbleD…

---

_[View the full topic](https://meta.discourse.org/t/i-want-to-update-rel-canonical-href-using-java-script/159527)._
