How can we set dynamically the siteInfo.siteTitle
ufukgursoy opened this issue · 1 comments
ufukgursoy commented
Hi,
I would like to set set dynamically the siteInfo.siteTitle startup.cs file.
Is there a any way to do it?
mjebrahimi commented
Hi, Ufuk
You can use
services.AddSeoTags(seoInfo =>
{
var siteTitle = "Anything you want"; //Read from env variable or database or settings
seoInfo.SetSiteInfo(siteTitle: siteTitle /* Other parameters is optional */);
});
Or if you want IServiceProvider to locate a registered service (for example read from a repository), use
services.AddSeoTags((serviceProvider, seoInfo) =>
{
var settingRepostory = serviceProvider.GetRequiredService<ISettingRepostory>();
var siteTitle = settingRepostory.GetSiteTitle();
seoInfo.SetSiteInfo(siteTitle: siteTitle /* Other parameters is optional */);
});