How to get content params from header file?

I have two questions with handling my header:
<meta name="twitter:image" content="{{ with .Params.image_main }}{{ . }}{{ else }}{{ with site.Params.logo }}{{ . }}{{ end }}{{ end }}.jpg">
That’s a twitter card that exists in my header file, I’m trying to access a image_main that exists in my content (.md) file to use that contents image this is not working.

Second questions is how can I access a absolute URL with with? As the output should look like this:
<meta name="twitter:image" content="">

In your content .md file, you need:

title: my content page
image_main: images/image_main.jpg

And then in your header something like this:

{{ with .Param "image_main" -}}
    <meta name="twitter:image" content="{{ . | absURL }}">
{{ end -}}

Using .Param likes this means you can also set a default image for content pages that do NOT have a image_main by setting the default in your config file:

  image_main: images/default_image.jpg

Thanks so much but I also have a condition to check if it exists, if not I want to use the logo. How would I do that?

The code I shared above pretty much already does this. The .Param first looks in the .md content file meta-data for image_main, and if it can’t find it, it goes and looks in your config.toml/config.yaml file for the image_main under params. Please check the docs for a full explanation of how .Param works.

So set image_main in your config file to images/my-logo.jpg, and then any page that does not have an image_main in its meta-data will use that instead.