question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat(router): Add `Route.metatags` and `Route.pageDescription` to Route definitions

See original GitHub issue

Which @angular/* package(s) are relevant/releated to the feature request?

@angular/router

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:open
  • Created 2 years ago
  • Reactions:34
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
lacolacocommented, Feb 11, 2022

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.

4reactions
fabioemoutinhocommented, Aug 12, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found