Answers.Body: <p>I’m not sure if those Tumblr URLs are just an incrementing ID (so each new post is +1 greater than the last one), or if it’s a randomly-generated string of numbers.</p>
  
  <p>If you just want yours to be the entry ID, all you’d have to do is go into your section’s settings, and set the following:</p>
  
  <ul>
  <li><strong>Do entries in this section have their own URLs?</strong> [check]</li>
  <li><strong>Entry URL Format:</strong> <code>post/{id}</code></li>
  </ul>
  
  <p>If you want it to be random, that’s a little more difficult. You would need to create a custom text field that stores the random number, attach it to your section, and start entering random numbers into it when creating new entries (or you could write a custom <a href="http://buildwithcraft.com/docs/plugins/field-types" rel="nofollow">field type</a> that handles this for you). Then your <strong>Entry URL Format</strong> would get set to <code>post/{customFieldHandle}</code> instead of <code>post/{id}</code>.</p>
  
  <p>As for the image URL, if you have an Assets field that’s responsible for storing the entry’s main image, you can set it to restrict uploads to a single directory, and give it a subfolder based on the entry’s ID/random number custom field handle. (See <a href="http://buildwithcraft.com/docs/assets-fields#restricting-uploads-to-a-single-folder" rel="nofollow">http://buildwithcraft.com/docs/assets-fields#restricting-uploads-to-a-single-folder</a>)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-18T13:45:13.330Z
Answers.LastActivityDate: 2014-09-18T13:45:13.330Z
Answers.UserDisplayName: Brandon Kelly
Answers.Body: <p>Entries have the <strong>url</strong> attribute, which you can access like so:</p>
  
  <pre><code>&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
  </code></pre>
  
  <p><a href="http://buildwithcraft.com/docs/templating/craft.entries" rel="nofollow">See example in the docs</a></p>
  
  <p>If you upload an image through Assets, you can get the url for the image by doing something like this:</p>
  
  <pre><code>&lt;img src="{{ entry.imageHandle.first().getUrl() }}" alt="" /&gt;
  </code></pre>
  
  <p>Note that the getUrl takes an optional transform name, if you have added any <a href="http://buildwithcraft.com/docs/image-transforms" rel="nofollow">transforms</a>.</p>
  
  <p>See more in the <a href="http://buildwithcraft.com/docs/templating/craft.assets" rel="nofollow">docs on craft.assets tag</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-18T10:17:25.580Z
Answers.Text: Hi Fred, sorry I meant auto URLs like "95032257420" instead of the URL title...
Answers.UserDisplayName: rey
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-18T23:53:14.863Z
Answers.Text: I wrote a plugin that allows you to generate strings like that: https://github.com/sjelfull/Craft-Randomm
Answers.UserDisplayName: Fred Carlsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-18T08:27:47.067Z
Answers.LastActivityDate: 2014-09-18T08:27:47.067Z
Answers.UserDisplayName: Fred Carlsen
Body: <p>How to auto-generate URLs in Craft? For example when we upload images on Tumblr, an URL to the post is created:</p>
  
  <p><a href="http://twotimeselliott.tumblr.com/post/95032257420" rel="nofollow">http://twotimeselliott.tumblr.com/post/95032257420</a></p>
  
  <p>And an URL for the image is created:</p>
  
  <p><a href="http://31.media.tumblr.com/2142197f5273865770be44723c2a5df0/tumblr_nagyr9INCE1r6ky2bo1_500.jpg" rel="nofollow">http://31.media.tumblr.com/2142197f5273865770be44723c2a5df0/tumblr_nagyr9INCE1r6ky2bo1_500.jpg</a></p>
  
  <p>How can we do that in Craft?</p>
  
Tags: <url>
Title: How to auto-generate URLs in Craft?
ThreadText: # How to auto-generate URLs in Craft?
  
  (Asked by: username_0 on 2014-09-18)
  
  How to auto-generate URLs in Craft? For example when we upload images on Tumblr, an URL to the post is created:
  
  <http://twotimeselliott.tumblr.com/post/95032257420>
  
  And an URL for the image is created:
  
  <http://31.media.tumblr.com/2142197f5273865770be44723c2a5df0/tumblr_nagyr9INCE1r6ky2bo1_500.jpg>
  
  How can we do that in Craft?
  
  **Tags:** url
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-09-18. Score: 3 | Accepted answer
  
  I’m not sure if those Tumblr URLs are just an incrementing ID (so each new post is +1 greater than the last one), or if it’s a randomly-generated string of numbers.
  
  If you just want yours to be the entry ID, all you’d have to do is go into your section’s settings, and set the following:
  
  * **Do entries in this section have their own URLs?** [check]
  * **Entry URL Format:** `post/{id}`
  
  If you want it to be random, that’s a little more difficult. You would need to create a custom text field that stores the random number, attach it to your section, and start entering random numbers into it when creating new entries (or you could write a custom [field type](http://buildwithcraft.com/docs/plugins/field-types) that handles this for you). Then your **Entry URL Format** would get set to `post/{customFieldHandle}` instead of `post/{id}`.
  
  As for the image URL, if you have an Assets field that’s responsible for storing the entry’s main image, you can set it to restrict uploads to a single directory, and give it a subfolder based on the entry’s ID/random number custom field handle. (See <http://buildwithcraft.com/docs/assets-fields#restricting-uploads-to-a-single-folder>)
  
  
  ---
  
  ### Answer by username_2 on 2014-09-18. Score: 0
  
  Entries have the **url** attribute, which you can access like so:
  
  ```
  <a href="{{ entry.url }}">{{ entry.title }}</a>
  
  ```
  
  [See example in the docs](http://buildwithcraft.com/docs/templating/craft.entries)
  
  If you upload an image through Assets, you can get the url for the image by doing something like this:
  
  ```
  <img src="{{ entry.imageHandle.first().getUrl() }}" alt="" />
  
  ```
  
  Note that the getUrl takes an optional transform name, if you have added any [transforms](http://buildwithcraft.com/docs/image-transforms).
  
  See more in the [docs on craft.assets tag](http://buildwithcraft.com/docs/templating/craft.assets).
  
  > **Comments:**
  > **username_0**: Hi username_2, sorry I meant auto URLs like "95032257420" instead of the URL title...  
  > **username_2**: I wrote a plugin that allows you to generate strings like that: https://github.com/sjelfull/Craft-Randomm  
  
  ---
  
  