How to extract book url in {{content}} from {{post_class}}

I am running a self-hosted host. Some of the posts on the home page are snippets from external blogs with bookmarks in the post body. When the post card is clicked, it opens the post content, and the reader can click on the bookmark to read the actual content. I don’t have permission to display the full content on my blog.

For posts like this with just a bookmark, I want to save viewers that extra click and take them to the post directly. In cards inside index.hbs, I want to extract the bookmark URL from the {{content}} in each {{post_class}}? If the bookmark URL exists, then I set the card URL as the bookmark URL; otherwise, I use {{url}}. Any idea how to do this?

I solved this for another user a couple weeks back.

In his case, he had blog post content on his index page already, so I wrote a piece of javascript that found the first bookmark in the posts with a specific internal tag, and used that URL to change the link after the page loaded. You could do something similar.

If you need a non-javascript solution, you could consider co-opting some existing field to store that URL. Perhaps the custom excerpt field, if you’re using a theme that doesn’t use it, but then you’d need to set up the metadata section manually…

Thanks for the response @Cathy_Sarisky. One final question; is there a way to prevent the page with that bookmark from being discovered by search engines?

You could use robots.txt to prevent search engines from indexing it. I’m not sure if it matters if they see it - if it really just has the bookmark content, they’re not likely to direct users to it.