Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

og:url not the same as the current visiting URL of translated pages, using TranslatedPress #15299

Closed
2 tasks done
realanthonyc opened this issue May 25, 2020 · 5 comments
Closed
2 tasks done

Comments

@realanthonyc
Copy link

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

I am using TranslatePress to create a multi-lang site. But social platforms tend to pick up wrong meta info when sharing translated pages. I have already configured all the meta info correctly, except og:url which Yoast adds to every page.

Currently, og:url outputs wrongly on translated pages. And there is no way to configure it and make it the same as the actual visiting URL.

My site default language is English. As the og:url is incorrect, when trying to share the translated posts via Facebook, LinkedIn, etc, no matter via “AddThis” or share natively by pasting links, it is not able to pick up the translated metadata, eg, title and description.

Please describe what you expected to happen and why.

og:url should always reflect the current visiting URL correctly.

(Btw, Are there any settings to configure og:url output? or to remove it?)

How can we reproduce this behavior?

It looks like in most cases, the og:url is incorrect. But some are correct which I have no idea why.

Incorrect:
view-source:https://cuhkintouch.cpr.cuhk.edu.hk/tc/
view-source:https://cuhkintouch.cpr.cuhk.edu.hk/tc/2020/03/2094/
view-source:https://cuhkintouch.cpr.cuhk.edu.hk/tc/2020/03/1645/
view-source:https://cuhkintouch.cpr.cuhk.edu.hk/tc/making-news/
view-source:https://cuhkintouch.cpr.cuhk.edu.hk/tc/privacy/
More: https://drive.google.com/drive/folders/1-Btq8fRPWHBnBG_iw-N0Tpvw9sIR4EKB?usp=sharing

Correct:
view-source:https://cuhkintouch.cpr.cuhk.edu.hk/tc/2020/03/311/
view-source:https://cuhkintouch.cpr.cuhk.edu.hk/tc/2020/02/752/

Technical info

Used versions

  • WordPress version: 5.4.1
  • Yoast SEO version: 14.1
  • TranslatePress version: 1.7.4
@Djennez
Copy link
Member

Djennez commented May 25, 2020

@anthonychan2509 thanks for the report.

As a workaround you can use the wpseo_opengraph_url filter.

I think this is indexables-related. Can you try resetting the indexables using the Yoast Test Helper plugin (Tools -> Yoast Test -> Reset indexables & migrations). Visit one of the problematic pages after that (without re-running the index) and see if that fixes the issue?

@sareiodata
Copy link

It's something we'll address in the next update of TranslatePress using

`add_filter( 'wpseo_opengraph_url', 'trpc_opengraph_url', 99999 );
function trpc_opengraph_url( $url ) {
global $TRP_LANGUAGE;
$trp = TRP_Translate_Press::get_trp_instance();
$url_converter = $trp->get_component( 'url_converter' );
$url = $url_converter->get_url_for_language($TRP_LANGUAGE, $url, '');

return $url;

}`

The same thing we're doing for the canonical, and the opengraph_url is based on the canonical, but without the canonical filter.

I didn't dig deep as to why the canonical is broke, but probably has something to do with the fact that TranslatePress filters the home_url() and adds the current language to it.

@realanthonyc
Copy link
Author

After following @Djennez instructions.

It looks like the og:url outputs are correct now,
EXCEPT for the home pages of the translated version.
Please see: /tc and /sc

@realanthonyc
Copy link
Author

One more update regarding the issue:

After "Reset indexables & migrations" with Yoast tool plugin, Yoast will prompt this message for building an index:

yoast-index

However, the og:url will be wrong again after taking this action. And I have to "Reset indexables & migrations".

@Djennez
Copy link
Member

Djennez commented Jul 8, 2020

Closing this as stale / related to #15141

@Djennez Djennez closed this as completed Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants