Unfortunately, you don’'t say what exactly is going wrong, but this should give you what you want:
<?php if ($page->intendedTemplate() == 'article') :?>
<meta name="keywords" content="<?php e($page->keywords()->isNotEmpty(), $page->keywords()->html(), $page->tags()->html()) ?>" />
<?php else: ?>
<meta name="keywords" content="<?php e($page->keywords()->isNotEmpty(), $page->keywords()->html(), $site->keywords()->html()) ?>" />
<?php endif ?>
I don’t know if your articles are called article.txt or something else, since your $article in the code above is not defined, so you need to adapt this if necessary.