2

In Sitecore 9, in the Content Editor and under the Presentation tab, there's an option to set Aliases on an item. Assuming you already have the desired item stored in variable $item, how would you set a new alias?

1 Answer 1

1

To create an alias, you just need to create an item under /sitecore/system/aliases using the template /sitecore/templates/System/Alias and fill in the required fields.

In SPE that would look something like

$aliasName = "Your Alias Name Here"
$newAlias = New-Item -Path "master:\system\aliases" -Name $aliasName -ItemType "system/alias"
$newAlias.Editing.BeginEdit()
$newAlias._."Linked Item".TargetID = $item.ID
$newAlias._."Linked Item".LinkType = "internal"
$newAlias.Editing.EndEdit();

That will create the alias item and set the linked item to the item in your $item variable.

The alias url is defined by the item name of the alias item. So you would need to set that to whatever you wanted the alias to be. Maybe with a Read-Variable to get the user input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.