Comments (14)
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.
Hello @fulls1z3 ,
Thank you for answer!
from ngx-meta.
@fulls1z3
Any idea if Facebook crawler can now read the meta tags set by, metadata.setTag('og:something', 'some value');
from ngx-meta.
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.
@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.
@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.
@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.
Sorry @chrillewoodz but that's not the topic of this issue, let's please discuss it under the appropriate one.
from ngx-meta.
@fulls1z3 Which is?
from ngx-meta.
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.
@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.
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.
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.
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)
- remove lodash peerDependency as it's not needed
- meta tags API call fails HOT 2
- meta doesn't get updated.
- upgrade to Angular 7 HOT 1
- Not fetching meta tags in web master HOT 1
- Make configurable callback exceptions HOT 2
- Default fallback on null instead of error (unless not defined in configuration)
- use with Angular i18n
- Set dynamic meta tags to use api call
- Allow use of ngx-meta in angular 8 project HOT 3
- Do you have any plan to apply for angular8? HOT 2
- Angular v9 support HOT 4
- The title does not display correctly in the browser history
- AOT Compiling Error - Function calls are not supported in decorators but 'MetaModule' was called HOT 7
- @ngx-meta/core Doesn't support Angular 11.X.X HOT 11
- Setting Tags from ts file.
- Linked-In Social Share issue HOT 1
- Uncaught TypeError: Cannot read property 'core' of undefined at ngx-meta-core.umd.js:4 HOT 1
- Angular 11/12 support HOT 6
- after ng update 12 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-meta.