# What is the best way to get the current URL for a canonical tag?

**URL:** https://discuss.ihp.digitallyinduced.com/t/what-is-the-best-way-to-get-the-current-url-for-a-canonical-tag/45
**Category:** General
**Created:** [March 4, 2024, 2:49pm UTC](https://discuss.ihp.digitallyinduced.com/t/what-is-the-best-way-to-get-the-current-url-for-a-canonical-tag/45 "2024-03-04T14:49:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nezbite](https://discuss.ihp.digitallyinduced.com/letter_avatar_proxy/v4/letter/n/aeb1de/32.png) [@nezbite](https://discuss.ihp.digitallyinduced.com/u/nezbite)
#### Post date: [March 4, 2024, 2:49pm UTC](https://discuss.ihp.digitallyinduced.com/t/what-is-the-best-way-to-get-the-current-url-for-a-canonical-tag/45/1 "2024-03-04T14:49:06Z")

</div>

For SEO reasons I need to include a canonical tag, that points to the current action. For the following reasons, this would be needed:

- Having 2 different URLs point to the same content
- Using more than one domain
- Having a bot generated URL for content, that usually only has one in the application (for example: `https://example.com/?ref=https://devpick.io`)

Our application has been a target of different third parties trying to influence our SEO by targeting our Server’s IP with a different domain or random bots adding ref query parameters to our URL on their sites. These issues can be fixed in multiple ways, the best general fix though, according to Google, is to use canonical links.

What would be the easiest way, to get the urlTo the current Action in the layout for the canonical tag?

Maybe adding an (optional) feature to IHP for a canonical tag using the url generated by `urlTo Action` or a recipe in the Guide would be a good idea.

---

<div class="post-metadata">

### Author: ![amitaibu](https://discuss.ihp.digitallyinduced.com/user_avatar/discuss.ihp.digitallyinduced.com/amitaibu/32/19_2.png) [@amitaibu](https://discuss.ihp.digitallyinduced.com/u/amitaibu)
#### Post date: [March 4, 2024, 7:00pm UTC](https://discuss.ihp.digitallyinduced.com/t/what-is-the-best-way-to-get-the-current-url-for-a-canonical-tag/45/2 "2024-03-04T19:00:05Z")

</div>

I think you should be able to get it by using something along these lines:

> <https://github.com/digitallyinduced/ihp/blob/13b55672120e07de109449069378590329ba6eda/IHP/ViewSupport.hs#L118-L121>

I believe that the `currentPath` is the canonical URL
