I’ve discovered whilst typing my question a small exchange on this at Adding a URL hash into meta data for Facebook and Twitter share cards which suggests that this may not be feasible but as things change over time I thought I’d seek guidance.
The scenario:
I have a URL http://example.com/ which includes appropriate Facebook meta in the header. I’m most interested in:
<meta property="og:image" content="whatever.jpg" />
At a later date I may add some additional info on the page and link to it with an anchor – e.g. http://example.com/#new and may want to display different meta for that anchor, e.g.
<meta property="og:image" content="whatever-another.jpg" />
My question is, is there any way to dynamically change the meta depending on whether the URL shared is the original URL or the URL with an anchor. The page could have multiple anchors.
My site uses WordPress so I can use things like custom fields, etc if they are a possible manual solution but whatever, the ability to change the meta field based on the URL anchor is the goal.
Appreciated any guidance.