brumate

Page metadata

#head adds tags to the <head> of the page, such as its <title>.

#head renders its content into the <head> of the page, for tags such as <meta> and <link>:

<script>
  import { $props } from 'brumate/signals';

  const { post } = $props<{ post: { title: string; summary: string; image: string } }>();
</script>

#head {
  <meta name="description" content=post.summary>
  <meta property="og:title" content=post.title>
  <meta property="og:image" content=post.image>
  <link rel="canonical" href=(`https://example.com/posts/${post.title}`)>
}

<h1>{post.title}</h1>

<title>

A <title> in #head sets the title of the page, as <meta> and <link> in #head add to the head:

<script>
  import { $memo, $signal } from 'brumate/signals';

  let todos = $signal([{ title: 'Write the docs', done: false }]);
  let editing = $signal(false);
  const left = $memo(todos.filter((todo) => !todo.done).length);
</script>

#head {
  <title>{`${left} left | Todos`}</title>
}

#if (editing) {
  #head {
    <title>Unsaved changes | Todos</title>
  }
}

$title(value) in a script does the same, and is replaced by a <title> in #head. The compiler warns about it, and it goes in a later version.

On navigation

When a link loads another page of the site without a full page load, the head follows the new page:

See Navigation.