feat(router): Add `Route.metatags` and `Route.pageDescription` to Route definitions
See original GitHub issueWhich @angular/* package(s) are relevant/releated to the feature request?
Description
As a follow up to #7630 it would be nice to also add both metatags
and pageDescription
to the router’s definition API in order to streamline how developers define routes.
We can also explore what other data is commonly defined and managed with custom strategies in the Route.data
property to see how else we could simplify Route definitions especially for new developers.
Proposed solution
const routes : Routes = {
path: '',
title: 'Angular Home Page',
metatags: ['home', 'angular'],
pageDescription: 'Home page for Angular documentation',
children: [
{path: 'about', title: 'About Angular', metatags: ['info', 'about'], pageDescription: 'About page for Angular documentation',},
{path: 'docs/:param', title: TitleResolver, metatags: MetatagResolver, pageDescription: PageDescriptionResolver}
]
};
Alternatives considered
Currently this is individually managed and already possible with the Route.data
additional attributes, which works but is more work for the developer and does not enforce best practices.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:34
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Emma Twersky on Twitter: "@realTomaszKula @angular there's an ...
feat (router): Add `Route.metatags` and `Route.pageDescription` to Route definitions · Issue #44928... Which @angular/* package(s) are relevant/releated to ...
Read more >Route Meta Fields | Vue Router
First, each route object in the routes configuration is called a route record. Route records may be nested. Therefore when a route is...
Read more >Add Title and Meta Tags for Each Route Component in React ...
Here we discuss the importance of adding title and meta tags for each route component in React and adding it using the react-helmet...
Read more >A simple way to keep your Vue page title in sync with the router
Step 1: Declare route meta in your router config. First things first, let's add some additional metadata to our standard routes:.
Read more >US9021112B2 - Content request routing and load balancing for ...
Node selection occurs when the network routing infrastructure selects a ... One such technique routes traffic to a content distribution site nearest the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree this feature would reduce COMMON efforts of developers, but my concern is the responsibility of routes. A route is not corresponding to the specific “page”. There are more variable usecases of Router, for example multiple router-outlets. I think adding meta or pageDescription fields to Route would mean Route is a model to represent a page. That may become a limitation for some of usecases. I think we need to discuss more about the essential mental model of Route.
Or, we just want to a customizable generic (no rxjs) callback place to update page information where we can manage title, meta and etc on the successful route change.
I love this idea. I was taking a look at best SEO practices and saw the new title feature for routes, which I guess was also added for improved SEO and/or a11y. I think meta tags make a lot of sense, thanks @twerske, I hope the proposal makes it into Angular in the future! I wonder if structured data as JSON/LD could also be considered: https://developers.google.com/search/docs/advanced/structured-data/intro-structured-data