-
Notifications
You must be signed in to change notification settings - Fork 2
Metadata
Sebastian Kolind Sørensen edited this page Feb 1, 2021
·
9 revisions
Pages, Posts, and Templates enable you to add metadata like title, description, and keywords directly in the header of the file. It is a very powerful feature of Volcano, which give you the ability to modify parts of your site from within a Post, Page or Template.
You write metadata like so:
<!--
* Title: My new page or post
* Description: I am just a regular page or post
* Written: 01/01/20 10:40:39
-->
# This is pretty awesome.
It is a breeze to get started, and lovely to work with😉
<?php
/**
* Title: All blog posts
* Description: This is all blog posts on my website
*/
$app = require __DIR__ . '/../../app.php';
foreach ($app->getEntries('posts') as $post) {
echo $post->link() . '<br />';
}
Later, when you want to show the meta data in your theme, you simply call the getMeta(string $type)
method like so:
<?php
$app = require __DIR__ . '/../../app.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My site — <?php echo $app->getMeta('title');?></title>
<meta name="description" content="<?php echo $app->getMeta('description');?>">
</head>
<body>
<?php echo $app->render(); ?>
</body>
</html>