# Inheritance (Extending)

If multiple of your files have a repetitive structure, you can define a template that your other files can extend. Templates can even extend other templates.

In your template you can define several blocks which you can then fill in the extending file.

{% code title="base.corgi" %}

```pug
block vars
  - lang := "en"

html(lang=lang)
head
  link(rel="stylesheet", href="/foo.css")
  title: block title
  block head
body: block body
```

{% endcode %}

{% tabs %}
{% tab title="Corgi" %}

<pre class="language-pug"><code class="lang-pug">extend "github.com/me/myproject/corgi/base.corgi"



<strong>block title Learn Corgi
</strong>
block body
  p
    > Head over to
      #a(href="https://mavolin.gitbook.io/corgi")[GitBook]
      to learn corgi!



</code></pre>

{% endtab %}

{% tab title="HTML" %}

```markup
<!doctype html>
<html lang="en">
<head>
  <link rel="stylesheet" href="/foo.css">
  <title>Learn Corgi</title>
</head>
<body>
  <p>
    Head over to
    <a href="https://mavolin.gitbook.io/corgi">GitBook</a>
    to learn corgi!
  </p>
</body>
</html>
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Corgi" %}

```pug
extend "base"

append vars
  - lang = "de"
  
block title Lerne Corgi
append head: link(rel="stylesheet", href="/fooz.css")

block body
  p 
    > Schau bei
      #a(href="https://mavolin.gitbook.io/corgi")[GitBook]
      vorbei, um corgi zu lernen!



```

{% endtab %}

{% tab title="HTML" %}

```markup
<!doctype html>
<html lang="de">
<head>
  <link rel="stylesheet" href="/foo.css">
  
  <title>Lerne Corgi</title>
  <link rel="stylesheet" href="/fooz.css">
</head>
<body>
  <p>
    Schau auf
    <a href="https://mavolin.gitbook.io/corgi">GitBook</a>
    vorbei, um corgi zu lernen!
  </p>
</body>
</html>
```

{% endtab %}
{% endtabs %}
