Giter Site home page Giter Site logo

setting og-tags about ngx-meta HOT 14 CLOSED

fulls1z3 avatar fulls1z3 commented on May 11, 2024
setting og-tags

from ngx-meta.

Comments (14)

fulls1z3 avatar fulls1z3 commented on May 11, 2024

Hi @meorfi,

Thanks for your interest in ng2-metadata.

You can use the setTag method to dynamically create meta tags, as well as you can define metadata right at the route definitions.

og: title and og:description are automatically duplicated using values from meta title and meta description.

In order to dynamically create any other og tag, you can use the following syntax within NgOnInit method of your components:

metadata.setTag('og:something', 'some value');

Generated metadata is not currently accessible by bots except Google crawler. For now, the only method to generate meta tags at the server-side in order to be crawl-able by bots such as facebook.

However, I'm keeping track of developments with those crawlers/bots and will publish updates as things become available.

from ngx-meta.

mihai-gritcan avatar mihai-gritcan commented on May 11, 2024

Hello @fulls1z3 ,
Thank you for answer!

from ngx-meta.

kodeine avatar kodeine commented on May 11, 2024

@fulls1z3
Any idea if Facebook crawler can now read the meta tags set by, metadata.setTag('og:something', 'some value');

from ngx-meta.

chrillewoodz avatar chrillewoodz commented on May 11, 2024

Generated metadata is not currently accessible by bots except Google crawler. For now, the only method to generate meta tags at the server-side in order to be crawl-able by bots such as facebook.

This does not seem to be the case, how would you explain that the dynamically set ones are read perfectly fine then?

from ngx-meta.

chrillewoodz avatar chrillewoodz commented on May 11, 2024

@kodeine This does seem to be the case, but I do not understand why that one works but the static ones doesn't.

@fulls1z3 Can you explain?

from ngx-meta.

fulls1z3 avatar fulls1z3 commented on May 11, 2024

@chrillewoodz have a look at @angular/universal docs, you can find there in-depth information and the necessity to create server-side re-rendering.

from ngx-meta.

chrillewoodz avatar chrillewoodz commented on May 11, 2024

@fulls1z3 That's not the issue here, and universal is not available in the CLI at this point so I can't do that unfortunately. I've tried for the last 4 months. The issue is that by setting tags with setTag function it works but when you define via router definition it doesn't. Are you doing anything differently when you apply the tags?

from ngx-meta.

fulls1z3 avatar fulls1z3 commented on May 11, 2024

Sorry @chrillewoodz but that's not the topic of this issue, let's please discuss it under the appropriate one.

from ngx-meta.

chrillewoodz avatar chrillewoodz commented on May 11, 2024

@fulls1z3 Which is?

from ngx-meta.

fulls1z3 avatar fulls1z3 commented on May 11, 2024

This issue is about the readability of meta tags generated by @nglibs/meta on Google crawler and Facebook crawler which uses different technologies.

Google crawler is configured to read meta tags generated on client-side (ex: Angular). However Facebook crawler (and many other such crawlers) do not have such a function yet. To cope with this, the idea of angular-universal had born, and been developed for SEO purposes.

You're talking about some other topic:

The issue is that by setting tags with setTag function it works but when you define via router definition it doesn't

So, please check the repository (README, issues, etc) and make your post below the appropriate one. If none exists, feel free to open a new issue.

Btw we're all glad about your feedbacks right here. Reporting issues are always a great contribution to this project. Thanks again :)

from ngx-meta.

chrillewoodz avatar chrillewoodz commented on May 11, 2024

@fulls1z3 Then my point is totally related to this topic. Metas set via setTag on client side can be read by Facebook without any problems. But if the same meta is set in the router definition, Facebook cannot read that. So no server-side rendering is needed when using setTag, but when setting via the router definition, it seems to be needed. I'm confused as to why the methods gives different results.

from ngx-meta.

fulls1z3 avatar fulls1z3 commented on May 11, 2024

The meta tags provided in route definitions are rendered when Angular fires the NavigationEnd event, because the url after redirects can only be retrieved then. However, invoking setTitle/setTag does render them immediately. That's why it shows different behaviours on these two different methods.

Earlier, Facebook crawler did not process immediate rendering, but it seems they made some progress though.

I need to check this in details, to provide crawling availability both with and without universal. Feel free to provide your thoughts.

Also, if you notice further issues, feel free to report them.

from ngx-meta.

chrillewoodz avatar chrillewoodz commented on May 11, 2024

Ok then I understand better. Perhaps you can call the methods on NavigationEnd as well? So that either way renders them immediately.

from ngx-meta.

fulls1z3 avatar fulls1z3 commented on May 11, 2024

Actually, it depends on Angular Router. But I see that they're enhancing the features all the time and am keeping an eye on it. When another event (fired much before than the NavigationEnd) is offered (with the same results that @nglibs/meta needs), then I can simply subscribe on that.

from ngx-meta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.