How do I add a # to my URLs with Laravel?

Published 5 months ago by p0t4t0

Just wanted to know how do I achieve something like site.com/page#someId

Best Answer (As Selected By p0t4t0)
p0t4t0

I figured it out but thanks for giving me an idea

{{ route('thread.show', [$thread->category->slug, $thread->slug]) }}#thread-{{ $thread->id }}
tykus
tykus
5 months ago (565,390 XP)

The only way I know to do this..

{{ url('/page') . '#someId' }}

or

{{ route('route.name') . '#someId' }}

You could create your own helper to make this more elegant if you preferred.

p0t4t0

@tykus would you happen to know how if an id was dynamic? I seem to get an error

{{ route('thread.show', [$thread->category->slug, $thread->slug]) . '#thread_{{ $thread->id }}' }}
p0t4t0

I figured it out but thanks for giving me an idea

{{ route('thread.show', [$thread->category->slug, $thread->slug]) }}#thread-{{ $thread->id }}

Please sign in or create an account to participate in this conversation.