Adding file path inside multiple html document



I have over 100 HTML file. I want to add the following code on each of the HTML document

<link rel="canonical" href="">

I would like to replace page-name.html with the current file path

Is there a script I could use to achieve this in on all the 100 documents?


Get the file path from an input

What operating system are you on?


I am on latest Mac


You could write a package that has access to the fs Node library, or you could dust off sed.


Thanks @DamnedScholar, I did try Sed, my lack of experience didn’t get me far. Might have to do it manually.