Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7514217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:25:53+00:00 2026-05-30T00:25:53+00:00

How can I get the current URL from a Twig template? I am using

  • 0

How can I get the current URL from a Twig template?

I am using Twig with PHP, without any other framework.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:25:55+00:00Added an answer on May 30, 2026 at 12:25 am

    Finding the current URL

    The current URL is supplied by your web server and written to the $_SERVER super-global. Run this small script, <?php echo '<pre>'; print_r($_SERVER);, through your server and root around to find the value(s) you are looking for.

    Related questions on this subject:

    • getting current URL
    • PHP Determining the current url
    • How to get URL of current page in PHP

    The PHP manual describes the nature of the available $_SERVER values here.

    Getting the URL in TWIG

    After you have the URL, you need to pass it as a template variable when calling render(...) on the Twig template instance. For example, you might code this.

    $current_url = // figure out what the current url is
    
    // pass the current URL as a variable to the template
    echo $template->render(array('current_url' => $current_url));
    

    To use the variable in the template, you use the {{ variable_name }} syntax.

    • Developer’s basic Twig documentation
    • Twig designer documentation for using variables.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can get in ASP.NET user name and password from URL? https://myUser:myPassword@myServer/ HttpContext.Current.Request.Url is
Using the current request I can get the URL hostname with: HttpContext.Current.Request.Url.Host But -
How can I get the current hour, minutes, and seconds from this? NSDate *now
I am trying to get the base URL from the worker role. I can't
How do you get the current path (url) from within an asp.net mvc view?
I can get the current page URL in a Firefox extension but I'd like
I have a URL that is being generated using GET variables from a form
I am currently using this script to get new data every second from record_count.php
I am actually using PHP but such crawling can be done by any programming
I need to get the hash # value from the current window url with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.