You can reference other content in a number of ways in Eggspress. The most reliable way is to use slugs.
What are slugs?
You use slugs in Eggspress to reference other files in your workspace.
Think of them as unique identifiers. They're like the ID number on a driver's license or the serial number on your computer or phone.
Slugs are optional, but we recommend using them to mitigate errors.
Good to know: Eggspress tries its best to locate the correct file when you have multiple files of the same name in your workspace. To eliminate the possibility of Eggspress puling up a file other than the one you intended on referencing, give your files unique names where possible.
Creating slugs
Slugs in Eggspress are derived from filenames. To build your own slug from a filename, follow these simple steps:
- Drop the file extension (e.g.
.md
,.jpg
, etc.) - Replace all spaces and underscores with hypens
- Convert everything to lowercase
To build a slug for the file located at my_posts/My First Post.md
, you would apply the steps above like so:
My First Post
(drop the extension)My-First_Post
(convert spaces and underscores to hyphens)my-first-post
(lowercase all)
Where to use slug
Throughout your content, you'll have opportunities to reference another file to pull in data from that file.
For example, we could pin the post that we just created a slug for in a sidebar by setting:
pinnedPost1: my-first-post
We may also reference this post from other posts as a previousPost
, nextPost
, and relatedPost
.
The same concept applies to all content items, including custom pages and author profiles.