not2easy wrote... When you mention using an 'if statement' that depends on how it is used which is not clear.
AwadGorg, yes, not2easy makes very important point... and I also agree with her that your question can be read several ways. I'll repeat the question and clarify the answer I posted...
I got this idea of using if statement to make the description at the header dynamic instead of a description of the site at all page will make a description of the page will this be better
As I reread this, I'm seeing it's not clear which "description" you're talking about... and I may well have misinterpreted.
What I was thinking that you wanted to do was to make your meta description dynamic... and by dynamic I interpreted that to mean that you would automate the process of making the descriptions different for each page and relating more closely to the content of each page. If your site is large, that is pretty much what Google suggests in the help article I linked to.
As I re-read it this time, I think you might be suggesting that since Google isn't using your meta description, and is instead using content from your "header" area, you should perhaps make the header content dynamic. Here in part it depends on finer details of what you mean by dynamic.... In my experience Google does look at the meta description first, and that's what I'd adjust first.
If Google doesn't think that the meta description is suitable for the page, though, it will then look elsewhere... eg, often starting with the content at the top of your page as the next most important thing, or sometimes instead looking at content that links to that page.
So, the meta description is really your best place to start, but there may be reasons why Google doesn't go with your meta description.
As mentioned, Google strongly prefers that the meta description be unique to each page. On the Help page I quote, I point out that Google also doesn't like "identical or similar descriptions on every page of a site". This suggests that the best place to start would be to see if your sitewide meta descriptions are the same or different, and if they are the same, to change each meta description so it is unique to each different page... ie, that they are all different from one another.
With very large sites where there are too many individual page meta descriptions to write manually, descriptions can be generated "dynamically" in a variety of ways, usually using pre-planned templates with blank spaces that (to oversimplify) can be filled in by material kept for this purpose, in a database keyed to the content of the page.
Your page content and words or phrases in the description both refer to the same targets you have "anticipated" for the page.
It's important to understand that the material that you want Google to display in the serps must be pre-coded into your pages before Google spiders them, so, and this is important, it must not be dynamic in the sense that it is reacting to the *query* that the page is returned for.
To change the content in response to the query, either in your meta desription or in your header, would be cloaking... a longer discussion. You must anticipate the core words or phrases your page will rank for, and use those onpage.
Your quoted paragraph above can be read also to suggest that you might make some material in your
"header" dynamic. But, as noted, Google looks at the meta description first... then compares it with the page content, your inbound links, and the rest of your site.
When I manually optimize a page, I never put a sitewide paragraph repeated in the header describing the site. I have an introductory paragraph instead about the particular page, and both that paragraph and the meta description on each page are similar enough, but with differences, that I'm generally happy with the description Google gives it. If you want to rewrite your headers too, that would be a great thing to do, but rewrite your meta descriptions first.
It may also be that your pages are too much alike in other ways, and Google is doing its best to differentiate them.
Note, btw, that the "nosnippets" meta tag, all by itself, as the Google article describes, may solve the problem, but I think a deeper approach might be worth the effort.
Hoping this makes sense.
Edited for clarification [edited by: Robert_Charlton at 12:38 am (utc) on Dec 5, 2019]