Change facebook meta data based on URL / Anchor

冷暖自知 提交于 2019-12-10 23:14:06

问题


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.

来源:https://stackoverflow.com/questions/26117418/change-facebook-meta-data-based-on-url-anchor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!