Get the generated slug for {{_permalink}}

Is there a way to get the generated slug in the CMS for a specific post (repeating content)? The idea is to put an ‘edit’ button that brings you to the right content on the dashboard. I can get the first part that looks something like ‘400a26fc’ but in the CMS i get ‘400a26fc-7bd5-4526-b68f-dd6908e9c82b’ and I cannot figure out how to get that last part.
Thanks !

I would like to know how to do this as well. Thank you.


I found a solution for this that works for me. It’s based on the fact that the {{_permalink}} seems to always append the end of the href with that page’s id.

document.addEventListener("DOMContentLoaded", function(event) {
  var emailEdit = document.getElementsByClassName("email-edit");
  for (var i=0; i < emailEdit.length; i++) {
    var emailLink = emailEdit[i].getAttribute("href")
    var emailID = /[^-]*$/.exec(emailLink)[0];
    emailEdit[i].href = "/dashboard/records/"+emailID+"/edit"

{{#section section-name multiple=true}}
      <a class="email-view" href="{{_permalink}}">View</a>
      <a class="email-edit" href="{{_permalink}}">Edit</a>

It only gives me the {{_id}} and not the the full href found in the CMS. :confused:

I’m not sure exactly what you mean. Are you trying to generate a link that will take the user directly to that page’s edit page in the dashboard? That’s what I created above – a landing page that has links to both view and edit the page. The {{_permalink} will generate a full href link to view the page but at the very end of it, it appends the page’s id. The javascript above takes that id and forms it into the href path needed to take the user to the edit page. Please let me know what I’m misunderstanding. Thx.

this is what i get for the edit link after running your script on local: http://localhost:3000/dashboard/records//videos/22/edit

and on deployed version :https://my-site-name/dashboard/records//videos/400a26fc/edit

Not sure why you’re getting the double slashes in front of video but otherwise it looks like what I think you’d want? What are the actual paths in the dashboard you’re trying to generate?

Yes in theory it would be, but there is a long slug generated in the CMS, so the actual href looks like this :

in local : http://localhost:3000/dashboard/records/22/edit

i can get the local version to work, but not the deployed one.

Ah gotcha. Well that kinda sucks haha. I haven’t actually tried deploying my site yet so didn’t realize :frowning:

I wonder if you use your own domain if they use the more simple ID’s. This script could still work though. I’d just need to modify it for production. Once I get there I’ll post back with a solution.

I just deployed my site and the path generated from the {{_permalink}} is taking me to 404 page doesn’t exist page. So confused right now :neutral_face:

what url are you getting?

This is how my URL, generated by {{_permalink}} looks on local (just for reference):

And this is how it looks on production:

The only page I can visit right now is the homepage:

No idea what is going on on your side, but i found a way to get the edit url for my posts, although it only works on prod and not on local.

$(document).ready(function () {
  var str, newUrl;
  $.each($('a[class*=getUrl]'), function (index, item) {
    str = $(item).attr('href');
    newUrl = '' + str + '/edit'
    $(item).attr('href', newUrl);

{{#section section-name multiple=true}}

      <a class="getUrl" href="{{_id}}">Edit</a>


That’s cool. I didn’t realize {{_id}} was a thing – does it just give you the id back or does it do something more than that?

it gives me the long string 400a26fc-7bd5-4526-b68f-dd6908e9c82b that is associated with the post. But it’s weird, on my local it gives me %7B%7Bvideos::_id%7D%7D, as if the {{_id}} doesn’t get interpreted.

Oh okay yeah I tested the {{_id}} when I first saw you mention it but tested on my local which gave me the same result you just mentioned. Huh, where did you find out about {{_id}}? I didn’t see it anywhere in the documentation. Makes me wonder if there’s other tags I don’t know about that could help to be aware of?

I can’t remember where i found it :laughing: .
But i just thought of something else ,{{_id}}/edit should work as well.


Nice! Yeah simple solution :slight_smile:

And I don’t know if there’s a more elegant solution or not but you could set something up in js that checks to see if you’re on local (checks for “localhost” in the url) and if it’s true, then change the path from the {{_id}} generated one to the other that works for local.

1 Like