An open API service indexing awesome lists of open source software.

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

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