Linking keywords to URLs automatically


(Julian) #1

Hi,

Has anyone ever found a way to take a list of keywords (possibly in CSV format) and get Squiz Matrix to scan all pages and turn those keywords into links that go to a search page with the keyword as a search term?

Our research organisation publishes a lot of white papers and various types of publications to its website, all of which are identified using a research ‘project code’. There are hundreds, maybe thousands of project codes mentioned on pages throuhgout the website.

I have a list of all our project codes, and i would like to import that list and convert all mentions of the project codes into links that go to the search page and execute a search.

i.e. If the scan found the project code <p>text....GRDC00321....text</p> it would convert it to <p>text....<a href="https://grdc.com.au/search?query=GRDC00321">GRDC00321</a>....text</p>

Any help, advice or ideas would be appreciated.


(Bart Banda) #2

Are you looking to do this automatically based on the contents of the page? So for example, if the word “GRDC00321” is found anywhere within the contents of the page, wrap it in an tag and link it to the search page?

If so, you would probably be best to do that client side with some JS that looks through the content and does a regex replace on the keywords.

I do a similar things with Matrix keywords on the Matrix docs site where I wrap all strings that start and end with a % sign in a tag, for example: https://matrix.squiz.net/manuals/keyword-replacements/chapters/conditional-keywords