Adding file path inside multiple html document


#1

Hi

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

<link rel="canonical" href="http://www.example.com/sub-folder/page-name.html">

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?

Thanks


Get the file path from an input
#2

What operating system are you on?


#3

I am on latest Mac


#4

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


#5

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