old_contents: from django import template
  
  register = template.Library()
  
  
  @register.simple_tag(takes_context=True)
  def pageurl(context, page):
      """
      Outputs a page's URL as relative (/foo/bar/) if it's within the same site as the
      current page, or absolute (http://example.com/foo/bar/) if not.
      """
      return page.relative_url(context['request'].site)
  
  @register.simple_tag(takes_context=True)
  def slugurl(context, slug):
      """Returns the URL for the page that has the given slug."""
      page = Page.objects.filter(slug=slug).first()
  
      if page:
          return page.relative_url(context['request'].site)
      else:
          return '#'
  
new_contents: from django import template
  
  from wagtail.wagtailcore.models import Page
  
  register = template.Library()
  
  
  @register.simple_tag(takes_context=True)
  def pageurl(context, page):
      """
      Outputs a page's URL as relative (/foo/bar/) if it's within the same site as the
      current page, or absolute (http://example.com/foo/bar/) if not.
      """
      return page.relative_url(context['request'].site)
  
  @register.simple_tag(takes_context=True)
  def slugurl(context, slug):
      """Returns the URL for the page that has the given slug."""
      page = Page.objects.filter(slug=slug).first()
  
      if page:
          return page.relative_url(context['request'].site)
      else:
          return '#'
  
subject: Add missing Page import