https://github.com/hflexgrig/seofriendlyspa
Aspnetcore SPA application with Angular js. Seo workaround for title and meta tags
https://github.com/hflexgrig/seofriendlyspa
angular aspnetcore metatags spa ssr
Last synced: about 1 month ago
JSON representation
Aspnetcore SPA application with Angular js. Seo workaround for title and meta tags
- Host: GitHub
- URL: https://github.com/hflexgrig/seofriendlyspa
- Owner: hflexgrig
- License: mit
- Created: 2024-07-25T14:11:04.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-23T22:28:33.000Z (almost 2 years ago)
- Last Synced: 2025-09-15T15:46:24.275Z (9 months ago)
- Topics: angular, aspnetcore, metatags, spa, ssr
- Language: TypeScript
- Homepage: https://medium.com/@haykflexgrigoryan/aspnetcore-angular-spa-application-with-seo-friendly-ssr-title-and-meta-tags-updates-bcef5f75b6ad
- Size: 22.3 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is ASPNetCore Angular SPA application, with Title and Meta tags update workaround on server side. It just proxies Angular routes,
which needed to be SEO friendly (check ClientApp/proxy.conf.js , where added "/item" and "/fetch-data") and then Appropriate routes created on SeoController
```
[HttpGet("item/{id}")]
public async Task Get(int id)
{
//Gets the data, to update meta tags and title
var item = await _itemsService.GetItem(id);
return await _seoService.SetMetasAndGetContentResult(item.Title,
new Dictionary()
{
{new HtmlMetaTagKey("name", "description"), item.Content},
{new HtmlMetaTagKey("name", "keywords"), $"buy in USA {item.Title}"},
{new HtmlMetaTagKey("property", "og:image"), item.ImagePath},
});
}
[HttpGet("fetch-data")]
public async Task GetFetchData()
{
//just updating random harcoded values for Title and Meta tags from the server
return await _seoService.SetMetasAndGetContentResult("Fetch data title set from the server",
new Dictionary()
{
{new HtmlMetaTagKey("name", "description"), "weather forecasts"},
{new HtmlMetaTagKey("name", "keywords"), $"weather USA"},
});
}
```
It reads the static Html content, and using AngleSharp updates the Title and existing Meta tags, or creates them, if they do not exist. (please check SeoService for implementation)
Please note!!!
This is only workaround for Title and Meta tags. If you need full SSR rendering , then check https://github.com/hflexgrig/MintPlayer.AspNetCore.SpaServices