When viewing the source code of the page, the script is there, but the canonical link is never added to the head section, even when the condition is verified.
I must do something wrong but I can’t find what. Any help would be greatly appreciated, thank you!
Your code is invalid simply because link is not a valid variable, it’s not declared anywhere, so it’s undefined. To be clear line 4 causes the error “Type error: link is undefined”. Have you seen line 2? there you declared a constant, link must exists so the correct way is const link = document.create and etc etc etc
@pietrofalco thanks a lot for your help!
It turned out that the link was properly generated, so I suppose that the original issue was due to a deployment issue with Webflow. I’m sorry for wasting your time
I’m really a noob at js, but from what I read don’t think that declaring the object is required. Assigning the value does create the variable. However, I also read that it was a good practice to declare it, so I did as you suggested anyway