Skip to content

Add dynamic OG/Twitter Card meta tags for challenge sharing using ngMeta#5051

Open
jaideepj2004 wants to merge 1 commit into
Cloud-CV:masterfrom
jaideepj2004:add-og-tags-ngmeta-3297
Open

Add dynamic OG/Twitter Card meta tags for challenge sharing using ngMeta#5051
jaideepj2004 wants to merge 1 commit into
Cloud-CV:masterfrom
jaideepj2004:add-og-tags-ngmeta-3297

Conversation

@jaideepj2004

Copy link
Copy Markdown
Contributor

Description

Fixes #3297

When a challenge link is shared on social media platforms (Twitter, LinkedIn, Facebook, etc.), the link preview currently shows generic EvalAI metadata instead of challenge-specific content. This PR integrates the ngMeta AngularJS library (as recommended by @RishabhJain2018) to dynamically update Open Graph and Twitter Card meta tags per challenge page.

Changes

1. bower.json

  • Added ngMeta (vinaygopinath/ngMeta) as a bower dependency.

2. frontend/app.scripts.json

  • Added ngMeta to the vendor scripts chunk with its minified path (bower_components/ngMeta/dest/ngMeta.min.js).

3. frontend/src/js/app.js

  • Added 'ngMeta' to the AngularJS module dependencies.
  • Added ngMetaProvider config block to set default meta values (title, description, image, url) used for non-challenge pages.

4. frontend/src/js/controllers/challengeCtrl.js

  • Injected ngMeta service into ChallengeCtrl.
  • After challenge data loads successfully, calls:
    • ngMeta.setTitle(details.title) — sets the page title to the challenge name.
    • ngMeta.setTag('description', details.short_description) — sets description to the challenge's short description.
    • ngMeta.setTag('image', vm.page.image) — sets image to the challenge logo.
    • ngMeta.setTag('url', window.location.href) — sets the canonical URL.

5. frontend/base.html

  • Updated <title> to use ng-bind="ngMeta.title + ngMeta.titleSuffix".
  • Updated og:title, og:description, og:image, og:url meta tags to use ng-attr-content bindings.
  • Added twitter:title, twitter:description, twitter:image meta tags with ng-attr-content bindings.

How to Test

  1. Run bower install to install the ngMeta dependency.
  2. Build and start the frontend (gulp dev or equivalent).
  3. Navigate to any challenge page (e.g., /web/challenges/challenge-page/{id}/overview).
  4. Inspect the <head> tags in browser DevTools — the og:title, og:description, and og:image values should reflect the challenge's title, short description, and logo.
  5. Navigate away from the challenge page — the meta tags should revert to the default EvalAI values.

Notes

  • short_description is used as the OG description; falls back to description if not set.
  • Default meta tags are configured for all non-challenge pages, maintaining backward compatibility.
  • The content fallback attributes on each meta tag ensure static parsers/crawlers still see meaningful values.

Fixes Cloud-CV#3297

- Add ngMeta (vinaygopinath/ngMeta) as a bower dependency
- Register ngMeta in app.scripts.json vendor bundle
- Add 'ngMeta' to AngularJS module dependencies in app.js
- Configure ngMeta defaults (title, description, image, url) in app config
- Inject ngMeta into ChallengeCtrl and set challenge-specific meta tags
  (title, short_description, image, current URL) after challenge data loads
- Update base.html to bind OG and Twitter Card meta tags via ngMeta
  ng-attr-content directives for dynamic per-challenge metadata

When a challenge page is visited, Open Graph and Twitter Card tags are
dynamically updated with the challenge title, short description, and
logo image, improving link preview appearance when challenge URLs are
shared on social media.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add metadata for challenges when a challenge link is shared

1 participant