<p>What I usually do in this scenario is to hide the default Title field and have it be automatically generated from one or more of the custom fields. The slug is then taken care of automatically from the title. This solution assumes that you're happy for the Title to be taken from the first few words of the Task:</p>
<ol>
<li>Go to the section's entry layout screen</li>
<li>Untick &quot;Show the Title field&quot;</li>
<li>Add some Twig code in the Title Format input (using <a href="https://craftquest.io/articles/twig-craft-cms-control-panel" rel="nofollow noreferrer">shortcut syntax</a> if you prefer) for how you want the auto title to be generated. For example, to take the first 120 characters of the &quot;Task&quot; field, minus any markup if it's a Redactor field, use the <code>striptags</code> filter and the <code>truncate</code> filter:</li>
</ol>
<p><code>{task|striptags|truncate(120, '...')}</code></p>
<p><a href="https://i.sstatic.net/v2YF3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/v2YF3.png" alt="A screenshot of the section settings screen" /></a></p>

CC BY-SA 4.0
2023-01-06T08:44:16.987Z
2023-01-06T10:54:20.023Z
2023-01-06T10:54:20.023Z
James Smith
<p>Is it possible to somehow generate a SLUG not from the title field, but, for example, from your own created field?</p>
<p>Example: A website for analyzing complex mathematical solutions. Each entry in the catalog is a solution to some mathematical task.
Each entry has fields:</p>
<ul>
<li>Title (goes by default)</li>
<li>Task (created text field)</li>
<li>Solution (created text field)</li>
</ul>
<p>By default, SLUG is formed from the &quot;Title&quot;. I want the SLUG to be formed from the field &quot;Task&quot;.
Is it possible to do this somehow in CRAFT CMS?</p>

<craft3><fieldtypes><slug>
How do I generate a slug based on another field?
# How do I generate a slug based on another field?

(Asked by: username_0 on 2023-01-06)

Is it possible to somehow generate a SLUG not from the title field, but, for example, from your own created field?

Example: A website for analyzing complex mathematical solutions. Each entry in the catalog is a solution to some mathematical task.
Each entry has fields:

* Title (goes by default)
* Task (created text field)
* Solution (created text field)

By default, SLUG is formed from the "Title". I want the SLUG to be formed from the field "Task".
Is it possible to do this somehow in CRAFT CMS?

**Tags:** craft3, fieldtypes, slug

---

## 1 answers

### Answer by username_1 on 2023-01-06. Score: 1 | Accepted answer

What I usually do in this scenario is to hide the default Title field and have it be automatically generated from one or more of the custom fields. The slug is then taken care of automatically from the title. This solution assumes that you're happy for the Title to be taken from the first few words of the Task:

1. Go to the section's entry layout screen
2. Untick "Show the Title field"
3. Add some Twig code in the Title Format input (using [shortcut syntax](https://craftquest.io/articles/twig-craft-cms-control-panel) if you prefer) for how you want the auto title to be generated. For example, to take the first 120 characters of the "Task" field, minus any markup if it's a Redactor field, use the `striptags` filter and the `truncate` filter:

`{task|striptags|truncate(120, '...')}`

[![A screenshot of the section settings screen](https://i.sstatic.net/v2YF3.png)](https://i.sstatic.net/v2YF3.png)


---

