Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we set dynamically the siteInfo.siteTitle #25

Open
ufukgursoy opened this issue Oct 14, 2022 · 1 comment
Open

How can we set dynamically the siteInfo.siteTitle #25

ufukgursoy opened this issue Oct 14, 2022 · 1 comment

Comments

@ufukgursoy
Copy link

Hi,

I would like to set set dynamically the siteInfo.siteTitle startup.cs file.
Is there a any way to do it?

@mjebrahimi
Copy link
Owner

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 */);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants